Skip to content

Commit

Permalink
fix: go version
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Nov 6, 2024
1 parent 669e5be commit 8debab4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
11 changes: 0 additions & 11 deletions pkg/config/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,17 +302,6 @@ func (l *Loader) handleGoVersion() {

l.cfg.LintersSettings.Gocritic.Go = trimmedGoVersion

// staticcheck related linters.
if l.cfg.LintersSettings.Staticcheck.GoVersion == "" {
l.cfg.LintersSettings.Staticcheck.GoVersion = trimmedGoVersion
}
if l.cfg.LintersSettings.Gosimple.GoVersion == "" {
l.cfg.LintersSettings.Gosimple.GoVersion = trimmedGoVersion
}
if l.cfg.LintersSettings.Stylecheck.GoVersion == "" {
l.cfg.LintersSettings.Stylecheck.GoVersion = trimmedGoVersion
}

os.Setenv("GOSECGOVERSION", l.cfg.Run.Go)
}

Expand Down
16 changes: 11 additions & 5 deletions pkg/goanalysis/runner_loadingpackage.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"go/types"
"os"
"reflect"
"strings"
"sync"
"sync/atomic"

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

// TODO(ldez) temporary workaround
rv, err := goutil.CleanRuntimeVersion()
if err != nil {
return err
var goVersion string
if pkg.Module != nil && pkg.Module.GoVersion != "" {
goVersion = "go" + strings.TrimPrefix(pkg.Module.GoVersion, "go")
} else {
var err error
goVersion, err = goutil.CleanRuntimeVersion()
if err != nil {
return err
}
}

tc := &types.Config{
Importer: importerFunc(importer),
Error: func(err error) {
pkg.Errors = append(pkg.Errors, lp.convertError(err)...)
},
GoVersion: rv, // TODO(ldez) temporary workaround
GoVersion: goVersion,
Sizes: types.SizesFor(build.Default.Compiler, build.Default.GOARCH),
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/lint/linter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (lc *Config) IsSlowLinter() bool {
}

func (lc *Config) WithLoadFiles() *Config {
lc.LoadMode |= packages.NeedName | packages.NeedFiles | packages.NeedCompiledGoFiles
lc.LoadMode |= packages.NeedName | packages.NeedFiles | packages.NeedCompiledGoFiles | packages.NeedModule
return lc
}

Expand Down

0 comments on commit 8debab4

Please # to comment.