File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,9 @@ import (
32
32
"strings"
33
33
)
34
34
35
+ // noGoModVersion disables the parsing of go version from go module file present in the project
36
+ const noGoModVersion = "GOSECNOMODVERSION"
37
+
35
38
// MatchCallByPackage ensures that the specified package is imported,
36
39
// adjusts the name for any aliases and ignores cases that are
37
40
// initialization only imports.
@@ -498,12 +501,13 @@ func RootPath(root string) (string, error) {
498
501
499
502
// GoVersion returns parsed version of Go mod version and fallback to runtime version if not found.
500
503
func GoVersion () (int , int , int ) {
501
- goVersion , err := goModVersion ()
502
- if err != nil {
503
- return parseGoVersion (strings .TrimPrefix (runtime .Version (), "go" ))
504
+ _ , ok := os .LookupEnv (noGoModVersion )
505
+ if ok {
506
+ if goModVersion , err := goModVersion (); err == nil {
507
+ return parseGoVersion (goModVersion )
508
+ }
504
509
}
505
-
506
- return parseGoVersion (goVersion )
510
+ return parseGoVersion (strings .TrimPrefix (runtime .Version (), "go" ))
507
511
}
508
512
509
513
type goListOutput struct {
You can’t perform that action at this time.
0 commit comments