File tree 3 files changed +12
-17
lines changed
3 files changed +12
-17
lines changed Original file line number Diff line number Diff line change @@ -302,17 +302,6 @@ func (l *Loader) handleGoVersion() {
302
302
303
303
l .cfg .LintersSettings .Gocritic .Go = trimmedGoVersion
304
304
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
-
316
305
os .Setenv ("GOSECGOVERSION" , l .cfg .Run .Go )
317
306
}
318
307
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import (
10
10
"go/types"
11
11
"os"
12
12
"reflect"
13
+ "strings"
13
14
"sync"
14
15
"sync/atomic"
15
16
@@ -153,18 +154,23 @@ func (lp *loadingPackage) loadFromSource(loadMode LoadMode) error {
153
154
return imp .Types , nil
154
155
}
155
156
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
+ }
160
166
}
161
167
162
168
tc := & types.Config {
163
169
Importer : importerFunc (importer ),
164
170
Error : func (err error ) {
165
171
pkg .Errors = append (pkg .Errors , lp .convertError (err )... )
166
172
},
167
- GoVersion : rv , // TODO(ldez) temporary workaround
173
+ GoVersion : goVersion ,
168
174
Sizes : types .SizesFor (build .Default .Compiler , build .Default .GOARCH ),
169
175
}
170
176
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ func (lc *Config) IsSlowLinter() bool {
81
81
}
82
82
83
83
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
85
85
return lc
86
86
}
87
87
You can’t perform that action at this time.
0 commit comments