1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00

improving code

This commit is contained in:
Carlos Alexandro Becker 2017-03-25 20:53:01 -03:00
parent 75aef323fb
commit 2885b24976
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
4 changed files with 58 additions and 50 deletions

View File

@ -84,47 +84,3 @@ func run(goos, goarch string, command []string) error {
}
return nil
}
// list from https://golang.org/doc/install/source#environment
var valids = []string{
"androidarm",
"darwin386",
"darwinamd64",
"darwinarm",
"darwinarm64",
"dragonflyamd64",
"freebsd386",
"freebsdamd64",
"freebsdarm",
"linux386",
"linuxamd64",
"linuxarm",
"linuxarm64",
"linuxppc64",
"linuxppc64le",
"linuxmips",
"linuxmipsle",
"linuxmips64",
"linuxmips64le",
"netbsd386",
"netbsdamd64",
"netbsdarm",
"openbsd386",
"openbsdamd64",
"openbsdarm",
"plan9386",
"plan9amd64",
"solarisamd64",
"windows386",
"windowsamd64",
}
func valid(goos, goarch string) bool {
var s = goos + goarch
for _, a := range valids {
if a == s {
return true
}
}
return false
}

View File

@ -9,9 +9,3 @@ import (
func TestDescription(t *testing.T) {
assert.NotEmpty(t, Pipe{}.Description())
}
func TestValid(t *testing.T) {
assert.True(t, valid("windows", "386"))
assert.True(t, valid("linux", "386"))
assert.False(t, valid("windows", "arm"))
}

View File

@ -0,0 +1,45 @@
package build
// list from https://golang.org/doc/install/source#environment
var valids = []string{
"androidarm",
"darwin386",
"darwinamd64",
"darwinarm",
"darwinarm64",
"dragonflyamd64",
"freebsd386",
"freebsdamd64",
"freebsdarm",
"linux386",
"linuxamd64",
"linuxarm",
"linuxarm64",
"linuxppc64",
"linuxppc64le",
"linuxmips",
"linuxmipsle",
"linuxmips64",
"linuxmips64le",
"netbsd386",
"netbsdamd64",
"netbsdarm",
"openbsd386",
"openbsdamd64",
"openbsdarm",
"plan9386",
"plan9amd64",
"solarisamd64",
"windows386",
"windowsamd64",
}
func valid(goos, goarch string) bool {
var s = goos + goarch
for _, a := range valids {
if a == s {
return true
}
}
return false
}

View File

@ -0,0 +1,13 @@
package build
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestValid(t *testing.T) {
assert.True(t, valid("windows", "386"))
assert.True(t, valid("linux", "386"))
assert.False(t, valid("windows", "arm"))
}