File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -54,8 +54,14 @@ type GoVersionInfo = util.SemVer
54
54
// 1. The Go version specified in the `go.work` file, if any.
55
55
// 2. The greatest Go version specified in any `go.mod` file, if any.
56
56
func (workspace * GoWorkspace ) RequiredGoVersion () util.SemVer {
57
- if workspace .WorkspaceFile != nil && workspace .WorkspaceFile .Go != nil {
58
- // If we have parsed a `go.work` file, return the version number from it.
57
+ // If we have parsed a `go.work` file, we prioritise versions from it over those in individual `go.mod`
58
+ // files. We are interested in toolchain versions, so if there is an explicit toolchain declaration in
59
+ // a `go.work` file, we use that. Otherwise, we fall back to the language version in the `go.work` file
60
+ // and use that as toolchain version. If we didn't parse a `go.work` file, then we try to find the
61
+ // greatest version contained in `go.mod` files.
62
+ if workspace .WorkspaceFile != nil && workspace .WorkspaceFile .Toolchain != nil {
63
+ return util .NewSemVer (workspace .WorkspaceFile .Toolchain .Name )
64
+ } else if workspace .WorkspaceFile != nil && workspace .WorkspaceFile .Go != nil {
59
65
return util .NewSemVer (workspace .WorkspaceFile .Go .Version )
60
66
} else if workspace .Modules != nil && len (workspace .Modules ) > 0 {
61
67
// Otherwise, if we have `go.work` files, find the greatest Go version in those.
You can’t perform that action at this time.
0 commit comments