Skip to content

Commit ae867cc

Browse files
committed
chore: move the Go detection inside the configuration loader
1 parent 0fb5f65 commit ae867cc

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

pkg/commands/run.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,6 @@ func (c *runCommand) persistentPreRunE(_ *cobra.Command, _ []string) error {
154154
return fmt.Errorf("can't load config: %w", err)
155155
}
156156

157-
if c.cfg.Run.Go == "" {
158-
c.cfg.Run.Go = config.DetectGoVersion()
159-
}
160-
161157
runtime.GOMAXPROCS(c.cfg.Run.Concurrency)
162158

163159
return c.startTracing()

pkg/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func IsGoGreaterThanOrEqual(current, limit string) bool {
7878
return v1.GreaterThanOrEqual(l)
7979
}
8080

81-
func DetectGoVersion() string {
81+
func detectGoVersion() string {
8282
file, _ := gomoddirectives.GetModuleFile()
8383

8484
if file != nil && file.Go != nil && file.Go.Version != "" {

pkg/config/loader.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,16 @@ func (r *Loader) Load() error {
4949
return err
5050
}
5151

52-
return r.parseConfig()
52+
err = r.parseConfig()
53+
if err != nil {
54+
return err
55+
}
56+
57+
if r.cfg.Run.Go == "" {
58+
r.cfg.Run.Go = detectGoVersion()
59+
}
60+
61+
return nil
5362
}
5463

5564
func (r *Loader) setConfigFile() error {

0 commit comments

Comments
 (0)