@@ -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
@@ -637,6 +637,8 @@ func goModSummary(m module.Version) (*modFileSummary, error) {
637
637
// its dependencies.
638
638
//
639
639
// rawGoModSummary cannot be used on the main module outside of workspace mode.
640
+ // The modFileSummary can still be used for retractions and deprecations
641
+ // even if a TooNewError is returned.
640
642
func rawGoModSummary (m module.Version ) (* modFileSummary , error ) {
641
643
if gover .IsToolchain (m .Path ) {
642
644
if m .Path == "go" && gover .Compare (m .Version , gover .GoStrictVersion ) >= 0 {
@@ -691,12 +693,7 @@ func rawGoModSummary(m module.Version) (*modFileSummary, error) {
691
693
summary .require = append (summary .require , req .Mod )
692
694
}
693
695
}
694
- if summary .goVersion != "" && gover .Compare (summary .goVersion , gover .GoStrictVersion ) >= 0 {
695
- if gover .Compare (summary .goVersion , gover .Local ()) > 0 {
696
- return nil , & gover.TooNewError {What : "module " + m .String (), GoVersion : summary .goVersion }
697
- }
698
- summary .require = append (summary .require , module.Version {Path : "go" , Version : summary .goVersion })
699
- }
696
+
700
697
if len (f .Retract ) > 0 {
701
698
summary .retract = make ([]retraction , 0 , len (f .Retract ))
702
699
for _ , ret := range f .Retract {
@@ -707,6 +704,16 @@ func rawGoModSummary(m module.Version) (*modFileSummary, error) {
707
704
}
708
705
}
709
706
707
+ // This block must be kept at the end of the function because the summary may
708
+ // be used for reading retractions or deprecations even if a TooNewError is
709
+ // returned.
710
+ if summary .goVersion != "" && gover .Compare (summary .goVersion , gover .GoStrictVersion ) >= 0 {
711
+ summary .require = append (summary .require , module.Version {Path : "go" , Version : summary .goVersion })
712
+ if gover .Compare (summary .goVersion , gover .Local ()) > 0 {
713
+ return summary , & gover.TooNewError {What : "module " + m .String (), GoVersion : summary .goVersion }
714
+ }
715
+ }
716
+
710
717
return summary , nil
711
718
})
712
719
}
0 commit comments