aboutsummaryrefslogtreecommitdiffhomepage
path: root/main_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2023-08-23 18:23:52 +0200
committerBjørn Erik Pedersen <[email protected]>2023-08-23 21:49:27 +0200
commit24b1be45c17d68c67bab61b2fbb568f53a3d8202 (patch)
tree4202ce89de8f523e051912e365bdf93b1a4422fd /main_test.go
parent111f02db2a2cb139a19e4643dd73fa637e40ad6e (diff)
downloadhugo-24b1be45c17d68c67bab61b2fbb568f53a3d8202.tar.gz
hugo-24b1be45c17d68c67bab61b2fbb568f53a3d8202.zip
Go 1.21 Upgrade
Fixes #11351
Diffstat (limited to 'main_test.go')
-rw-r--r--main_test.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/main_test.go b/main_test.go
index c5a59828f..eda829dbb 100644
--- a/main_test.go
+++ b/main_test.go
@@ -396,8 +396,13 @@ func testSetupFunc() func(env *testscript.Env) error {
keyVals = append(keyVals, "SOURCE", sourceDir)
goVersion := runtime.Version()
- // Strip all but the major and minor version.
- goVersion = regexp.MustCompile(`^go(\d+\.\d+)`).FindStringSubmatch(goVersion)[1]
+
+ goVersion = strings.TrimPrefix(goVersion, "go")
+ if !strings.HasSuffix(goVersion, ".0") {
+ // Strip patch version.
+ goVersion = goVersion[:strings.LastIndex(goVersion, ".")]
+ }
+
keyVals = append(keyVals, "GOVERSION", goVersion)
envhelpers.SetEnvVars(&env.Vars, keyVals...)