Skip to content

Commit 8debab4

Browse files
committed
fix: go version
1 parent 669e5be commit 8debab4

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

pkg/config/loader.go

-11
Original file line numberDiff line numberDiff line change
@@ -302,17 +302,6 @@ func (l *Loader) handleGoVersion() {
302302

303303
l.cfg.LintersSettings.Gocritic.Go = trimmedGoVersion
304304

305-
// staticcheck related linters.
306-
if l.cfg.LintersSettings.Staticcheck.GoVersion == "" {
307-
l.cfg.LintersSettings.Staticcheck.GoVersion = trimmedGoVersion
308-
}
309-
if l.cfg.LintersSettings.Gosimple.GoVersion == "" {
310-
l.cfg.LintersSettings.Gosimple.GoVersion = trimmedGoVersion
311-
}
312-
if l.cfg.LintersSettings.Stylecheck.GoVersion == "" {
313-
l.cfg.LintersSettings.Stylecheck.GoVersion = trimmedGoVersion
314-
}
315-
316305
os.Setenv("GOSECGOVERSION", l.cfg.Run.Go)
317306
}
318307

pkg/goanalysis/runner_loadingpackage.go

+11-5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"go/types"
1111
"os"
1212
"reflect"
13+
"strings"
1314
"sync"
1415
"sync/atomic"
1516

@@ -153,18 +154,23 @@ func (lp *loadingPackage) loadFromSource(loadMode LoadMode) error {
153154
return imp.Types, nil
154155
}
155156

156-
// TODO(ldez) temporary workaround
157-
rv, err := goutil.CleanRuntimeVersion()
158-
if err != nil {
159-
return err
157+
var goVersion string
158+
if pkg.Module != nil && pkg.Module.GoVersion != "" {
159+
goVersion = "go" + strings.TrimPrefix(pkg.Module.GoVersion, "go")
160+
} else {
161+
var err error
162+
goVersion, err = goutil.CleanRuntimeVersion()
163+
if err != nil {
164+
return err
165+
}
160166
}
161167

162168
tc := &types.Config{
163169
Importer: importerFunc(importer),
164170
Error: func(err error) {
165171
pkg.Errors = append(pkg.Errors, lp.convertError(err)...)
166172
},
167-
GoVersion: rv, // TODO(ldez) temporary workaround
173+
GoVersion: goVersion,
168174
Sizes: types.SizesFor(build.Default.Compiler, build.Default.GOARCH),
169175
}
170176

pkg/lint/linter/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (lc *Config) IsSlowLinter() bool {
8181
}
8282

8383
func (lc *Config) WithLoadFiles() *Config {
84-
lc.LoadMode |= packages.NeedName | packages.NeedFiles | packages.NeedCompiledGoFiles
84+
lc.LoadMode |= packages.NeedName | packages.NeedFiles | packages.NeedCompiledGoFiles | packages.NeedModule
8585
return lc
8686
}
8787

0 commit comments

Comments
 (0)