@@ -10,8 +10,15 @@ import (
10
10
"strings"
11
11
)
12
12
13
- // GoVersion checks the go version by running "go list" with modules off.
14
- // It returns the X in Go 1.X.
13
+ // GoVersion reports the minor version number of the highest release
14
+ // tag built into the go command on the PATH.
15
+ //
16
+ // Note that this may be higher than the version of the go tool used
17
+ // to build this application, and thus the versions of the standard
18
+ // go/{scanner,parser,ast,types} packages that are linked into it.
19
+ // In that case, callers should either downgrade to the version of
20
+ // go used to build the application, or report an error that the
21
+ // application is too old to use the go command on the PATH.
15
22
func GoVersion (ctx context.Context , inv Invocation , r * Runner ) (int , error ) {
16
23
inv .Verb = "list"
17
24
inv .Args = []string {"-e" , "-f" , `{{context.ReleaseTags}}` , `--` , `unsafe` }
@@ -38,7 +45,7 @@ func GoVersion(ctx context.Context, inv Invocation, r *Runner) (int, error) {
38
45
if len (stdout ) < 3 {
39
46
return 0 , fmt .Errorf ("bad ReleaseTags output: %q" , stdout )
40
47
}
41
- // Split up "[go1.1 go1.15]"
48
+ // Split up "[go1.1 go1.15]" and return highest go1.X value.
42
49
tags := strings .Fields (stdout [1 : len (stdout )- 2 ])
43
50
for i := len (tags ) - 1 ; i >= 0 ; i -- {
44
51
var version int
0 commit comments