Skip to content

Commit 0a06a89

Browse files
committed
fix: yes it's a hack...
1 parent 74f0879 commit 0a06a89

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

pkg/commands/executor.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,18 @@ func NewExecutor(buildInfo BuildInfo) *Executor {
116116
e.log.Fatalf("Can't read config: %s", err)
117117
}
118118

119-
if (commandLineCfg == nil || commandLineCfg.Run.Go == "") && e.cfg != nil && e.cfg.Run.Go == "" {
119+
if commandLineCfg != nil && commandLineCfg.Run.Go != "" {
120+
// This hack allow to have the right Run information at least for the Go version (because the default value of the "go" flag is empty).
121+
// If you put a log for `m.cfg.Run.Go` inside `GetAllSupportedLinterConfigs`,
122+
// you will observe that at end (without this hack) the value will have the right value but too late,
123+
// the linters are already running with the previous uncompleted configuration.
124+
// TODO(ldez) there is a major problem with the executor:
125+
// the parsing of the configuration and the timing to load the configuration and linters are creating unmanageable situations.
126+
// There is no simple solution because it's spaghetti code.
127+
// I need to completely rewrite the command line system and the executor because it's extremely time consuming to debug,
128+
// so it's unmaintainable.
129+
e.cfg.Run.Go = commandLineCfg.Run.Go
130+
} else if e.cfg.Run.Go == "" {
120131
e.cfg.Run.Go = config.DetectGoVersion()
121132
}
122133

pkg/lint/linter/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package linter
22

33
import (
4-
"errors"
4+
"fmt"
55

66
"golang.org/x/tools/go/packages"
77

@@ -151,7 +151,7 @@ func IsGoLowerThanGo122() func(cfg *config.Config) error {
151151
return nil
152152
}
153153

154-
return errors.New("this linter is disabled because the Go version of your project is lower than Go 1.22")
154+
return fmt.Errorf("this linter is disabled because the Go version (%s) of your project is lower than Go 1.22", cfg.Run.Go)
155155
}
156156
}
157157

test/linters_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func testOneSource(t *testing.T, log *logutils.StderrLog, binPath, sourcePath st
8484
}
8585

8686
args := []string{
87-
"--allow-parallel-runners",
87+
"--go=1.22", // TODO(ldez) remove this line when we will run go1.23 on the CI. (related to intrange, copyloopvar)
8888
"--disable-all",
8989
"--out-format=json",
9090
"--max-same-issues=100",
@@ -99,7 +99,6 @@ func testOneSource(t *testing.T, log *logutils.StderrLog, binPath, sourcePath st
9999

100100
cmd := testshared.NewRunnerBuilder(t).
101101
WithBinPath(binPath).
102-
WithNoParallelRunners().
103102
WithArgs(caseArgs...).
104103
WithRunContext(rc).
105104
WithTargetPath(sourcePath).

0 commit comments

Comments
 (0)