@@ -190,7 +190,7 @@ func CheckRetractions(ctx context.Context, m module.Version) (err error) {
190
190
return err
191
191
}
192
192
summary , err := rawGoModSummary (rm )
193
- if err != nil {
193
+ if err != nil && ! errors . Is ( err , gover . ErrTooNew ) {
194
194
return err
195
195
}
196
196
@@ -298,7 +298,7 @@ func CheckDeprecation(ctx context.Context, m module.Version) (deprecation string
298
298
return "" , err
299
299
}
300
300
summary , err := rawGoModSummary (latest )
301
- if err != nil {
301
+ if err != nil && ! errors . Is ( err , gover . ErrTooNew ) {
302
302
return "" , err
303
303
}
304
304
return summary .deprecated , nil
@@ -644,6 +644,8 @@ func goModSummary(m module.Version) (*modFileSummary, error) {
644
644
// its dependencies.
645
645
//
646
646
// rawGoModSummary cannot be used on the main module outside of workspace mode.
647
+ // The modFileSummary can still be used for retractions and deprecations
648
+ // even if a TooNewError is returned.
647
649
func rawGoModSummary (m module.Version ) (* modFileSummary , error ) {
648
650
if gover .IsToolchain (m .Path ) {
649
651
if m .Path == "go" && gover .Compare (m .Version , gover .GoStrictVersion ) >= 0 {
@@ -698,12 +700,7 @@ func rawGoModSummary(m module.Version) (*modFileSummary, error) {
698
700
summary .require = append (summary .require , req .Mod )
699
701
}
700
702
}
701
- if summary .goVersion != "" && gover .Compare (summary .goVersion , gover .GoStrictVersion ) >= 0 {
702
- if gover .Compare (summary .goVersion , gover .Local ()) > 0 {
703
- return nil , & gover.TooNewError {What : "module " + m .String (), GoVersion : summary .goVersion }
704
- }
705
- summary .require = append (summary .require , module.Version {Path : "go" , Version : summary .goVersion })
706
- }
703
+
707
704
if len (f .Retract ) > 0 {
708
705
summary .retract = make ([]retraction , 0 , len (f .Retract ))
709
706
for _ , ret := range f .Retract {
@@ -714,6 +711,16 @@ func rawGoModSummary(m module.Version) (*modFileSummary, error) {
714
711
}
715
712
}
716
713
714
+ // This block must be kept at the end of the function because the summary may
715
+ // be used for reading retractions or deprecations even if a TooNewError is
716
+ // returned.
717
+ if summary .goVersion != "" && gover .Compare (summary .goVersion , gover .GoStrictVersion ) >= 0 {
718
+ summary .require = append (summary .require , module.Version {Path : "go" , Version : summary .goVersion })
719
+ if gover .Compare (summary .goVersion , gover .Local ()) > 0 {
720
+ return summary , & gover.TooNewError {What : "module " + m .String (), GoVersion : summary .goVersion }
721
+ }
722
+ }
723
+
717
724
return summary , nil
718
725
})
719
726
}
0 commit comments