Skip to content

Commit

Permalink
feat: better Go detection
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Mar 22, 2022
1 parent 10219c8 commit d464c12
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pkg/config/config.go
@@ -1,6 +1,7 @@
package config

import (
"os"
"strings"

hcversion "github.com/hashicorp/go-version"
Expand Down Expand Up @@ -54,16 +55,16 @@ func IsGreaterThanOrEqualGo118(v string) bool {
}

func DetectGoVersion() string {
const defaultGo = "1.17"

file, err := gomoddirectives.GetModuleFile()
if err != nil {
return defaultGo
}
file, _ := gomoddirectives.GetModuleFile()

if file != nil && file.Go != nil {
return file.Go.Version
}

return defaultGo
v := os.Getenv("GOVERSION")
if v != "" {
return v
}

return "1.17"
}

0 comments on commit d464c12

Please sign in to comment.