1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-02-05 13:15:26 +02:00

fix: improve linux.Arch

should affect snapcraft and nfpm
This commit is contained in:
Carlos Alexandro Becker 2019-03-19 21:45:34 -03:00
parent 486d5303fd
commit 3395bf1719
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
2 changed files with 16 additions and 19 deletions

View File

@ -4,22 +4,19 @@ package linux
import "strings"
// Arch converts a goarch to a linux-compatible arch
//
// list of all linux arches: `go tool dist list | grep linux`
func Arch(key string) string {
switch {
case strings.Contains(key, "amd64"):
return "amd64"
case strings.Contains(key, "386"):
var arch = strings.TrimPrefix(key, "linux")
switch arch {
case "386":
return "i386"
case strings.Contains(key, "arm64"):
return "arm64"
case strings.Contains(key, "arm6"):
case "amd64":
return "amd64"
case "arm6": // GOARCH + GOARM
return "armel"
case strings.Contains(key, "arm7"):
case "arm7": // GOARCH + GOARM
return "armhf"
case strings.Contains(key, "ppc64le"):
return "ppc64le"
case strings.Contains(key, "ppc64"):
return "ppc64"
}
return key
return arch
}

View File

@ -9,12 +9,12 @@ import (
func TestArch(t *testing.T) {
for from, to := range map[string]string{
"amd64": "amd64",
"386": "i386",
"arm64": "arm64",
"arm6": "armel",
"arm7": "armhf",
"what": "what",
"linuxamd64": "amd64",
"linux386": "i386",
"linuxarm64": "arm64",
"linuxarm6": "armel",
"linuxarm7": "armhf",
"linuxwhat": "what",
} {
t.Run(fmt.Sprintf("%s to %s", from, to), func(t *testing.T) {
assert.Equal(t, to, Arch(from))