From 60634f7476526d461687786b55dfad5512d962ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 17 Jan 2025 00:54:30 +0000 Subject: [PATCH] internal/linker: use go/version to get the Go major version --- internal/linker/linker.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/internal/linker/linker.go b/internal/linker/linker.go index bc8fa82..293ec6a 100644 --- a/internal/linker/linker.go +++ b/internal/linker/linker.go @@ -10,6 +10,7 @@ import ( "encoding/base64" "encoding/json" "fmt" + "go/version" "io" "io/fs" "os" @@ -211,11 +212,7 @@ func buildLinker(workingDir string, overlay map[string]string, outputLinkPath st } func PatchLinker(goRoot, goVersion, cacheDir, tempDir string) (string, func(), error) { - // rxVersion looks for a version like "go1.19" or "go1.20" - rxVersion := regexp.MustCompile(`go\d+\.\d+`) - majorGoVersion := rxVersion.FindString(goVersion) - - patchesVer, modFiles, patches, err := loadLinkerPatches(majorGoVersion) + patchesVer, modFiles, patches, err := loadLinkerPatches(version.Lang(goVersion)) if err != nil { return "", nil, fmt.Errorf("cannot retrieve linker patches: %v", err) }