@@ -15,7 +15,7 @@ import (
1515
1616const (
1717 // GolangCIVersion to be used for linting.
18- GolangCIVersion = "github.com/golangci/golangci-lint/cmd/golangci-lint@v1.58.1 "
18+ GolangCIVersion = "github.com/golangci/golangci-lint/cmd/golangci-lint@latest "
1919)
2020
2121// GOBIN environment variable.
@@ -51,13 +51,18 @@ func main() {
5151func lint (depth int64 ) {
5252 v := flag .Bool ("v" , false , "log verbosely" )
5353
54+ // Ensure we use the correct Go toolchain
55+ env := os .Environ ()
56+ env = append (env , "GOTOOLCHAIN=auto" )
57+
5458 // Make sure GOLANGCI is downloaded and available.
5559 argsGet := []string {"install" , GolangCIVersion }
5660 cmd := exec .Command (filepath .Join (runtime .GOROOT (), "bin" , "go" ), argsGet ... )
61+ cmd .Env = env
5762
5863 out , err := cmd .CombinedOutput ()
5964 if err != nil {
60- log .Fatalf ("could not list pkgs : %v\n %s" , err , string (out ))
65+ log .Fatalf ("could not install golangci-lint : %v\n %s" , err , string (out ))
6166 }
6267
6368 cmd = exec .Command (filepath .Join (goBin (), "golangci-lint" ))
@@ -72,10 +77,13 @@ func lint(depth int64) {
7277 cmd .Args = append (cmd .Args , "-v" )
7378 }
7479
80+ // Set environment for golangci-lint
81+ cmd .Env = env
82+
7583 fmt .Println ("Linting..." )
7684 cmd .Stderr , cmd .Stdout = os .Stderr , os .Stdout
7785
7886 if err := cmd .Run (); err != nil {
79- log .Fatal ("Error: Could not Lint " , "error: " , err , ", cmd: " , cmd )
87+ log .Fatal ("Error: Could not Lint " , "error" , err , ", cmd" , cmd )
8088 }
8189}
0 commit comments