Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Update Platforms to Go 1.9
Browse files Browse the repository at this point in the history
This adds all platforms up to Go 1.9
Tests are updated to support Go versions > 1.5
The OsList and ArchList variables are removed as they appear unused

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
  • Loading branch information
dave-tucker committed Feb 23, 2018
1 parent 5b2a53e commit dd49e0a
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 32 deletions.
12 changes: 7 additions & 5 deletions go_test.go
Expand Up @@ -12,11 +12,13 @@ func TestGoVersion(t *testing.T) {
}

acceptable := []string{
"devel", "go1.0", "go1.1", "go1.2", "go1.3", "go1.4.2", "go1.5",
"go1.5.1", "go1.5.2", "go1.5.3", "go1.5.4", "go1.6", "go1.6.1",
"go1.6.2", "go1.6.3", "go1.6.4", "go1.7", "go1.7.1", "go1.7.2",
"go1.7.3", "go1.7.4", "go1.7.5", "go1.8", "go1.8.1", "go1.8.2",
"go1.8.3", "go1.8.4", "go1.8.5", "go1.9", "go1.9.1", "go1.9.2",
"devel", "go1.0", "go1.1", "go1.2", "go1.3",
"go1.4", "go1.4.1", "go1.4.2", "go1.4.3",
"go1.5", "go1.5.1", "go1.5.2", "go1.5.3", "go1.5.4",
"go1.6", "go1.6.1", "go1.6.2", "go1.6.3", "go1.6.4",
"go1.7", "go1.7.1", "go1.7.2", "go1.7.3", "go1.7.4", "go1.7.5", "go1.7.6",
"go1.8", "go1.8.1", "go1.8.2", "go1.8.3", "go1.8.4",
"go1.9", "go1.9.1", "go1.9.2",
}
found := false
for _, expected := range acceptable {
Expand Down
59 changes: 33 additions & 26 deletions platform.go
Expand Up @@ -26,27 +26,6 @@ func (p *Platform) String() string {
}

var (
OsList = []string{
"darwin",
"dragonfly",
"freebsd",
"linux",
"netbsd",
"openbsd",
"plan9",
"solaris",
"windows",
}

ArchList = []string{
"386",
"amd64",
"arm",
"arm64",
"ppc64",
"ppc64le",
}

Platforms_1_0 = []Platform{
{"darwin", "386", true},
{"darwin", "amd64", true},
Expand Down Expand Up @@ -90,14 +69,38 @@ var (
{"linux", "ppc64", false},
{"linux", "ppc64le", false},
}...)

Platforms_1_6 = append(Platforms_1_5, []Platform{
{"android", "386", false},
{"linux", "mips64", false},
{"linux", "mips64le", false},
}...)

Platforms_1_7 = append(Platforms_1_5, []Platform{
// While not fully supported s390x is generally useful
{"linux", "s390x", true},
{"plan9", "arm", false},
// Add the 1.6 Platforms, but reflect full support for mips64 and mips64le
{"android", "386", false},
{"linux", "mips64", true},
{"linux", "mips64le", true},
}...)

Platforms_1_8 = append(Platforms_1_7, []Platform{
{"linux", "mips", true},
{"linux", "mipsle", true},
}...)

// no new platforms in 1.9
Platforms_1_9 = Platforms_1_8
)

// SupportedPlatforms returns the full list of supported platforms for
// the version of Go that is
func SupportedPlatforms(v string) []Platform {
// Use latest if we get an unexpected version string
if !strings.HasPrefix(v, "go") {
return Platforms_1_5
return Platforms_1_9
}
// go-version only cares about version numbers
v = v[2:]
Expand All @@ -106,8 +109,8 @@ func SupportedPlatforms(v string) []Platform {
if err != nil {
log.Printf("Unable to parse current go version: %s\n%s", v, err.Error())

// Default to 1.5
return Platforms_1_5
// Default to 1.9
return Platforms_1_9
}

var platforms = []struct {
Expand All @@ -118,7 +121,11 @@ func SupportedPlatforms(v string) []Platform {
{">= 1.1, < 1.3", Platforms_1_1},
{">= 1.3, < 1.4", Platforms_1_3},
{">= 1.4, < 1.5", Platforms_1_4},
{">= 1.5", Platforms_1_5},
{">= 1.5, < 1.6", Platforms_1_5},
{">= 1.6, < 1.7", Platforms_1_6},
{">= 1.7, < 1.8", Platforms_1_7},
{">= 1.8, < 1.9", Platforms_1_8},
{">= 1.9, < 1.10", Platforms_1_9},
}

for _, p := range platforms {
Expand All @@ -132,5 +139,5 @@ func SupportedPlatforms(v string) []Platform {
}

// Assume latest
return Platforms_1_5
return Platforms_1_9
}
39 changes: 38 additions & 1 deletion platform_test.go
Expand Up @@ -33,9 +33,46 @@ func TestSupportedPlatforms(t *testing.T) {
t.Fatalf("bad: %#v", ps)
}

ps = SupportedPlatforms("go1.5")
if !reflect.DeepEqual(ps, Platforms_1_5) {
t.Fatalf("bad: %#v", ps)
}

ps = SupportedPlatforms("go1.6")
if !reflect.DeepEqual(ps, Platforms_1_6) {
t.Fatalf("bad: %#v", ps)
}

ps = SupportedPlatforms("go1.7")
if !reflect.DeepEqual(ps, Platforms_1_7) {
t.Fatalf("bad: %#v", ps)
}

ps = SupportedPlatforms("go1.8")
if !reflect.DeepEqual(ps, Platforms_1_8) {
t.Fatalf("bad: %#v", ps)
}

// Unknown
ps = SupportedPlatforms("foo")
if !reflect.DeepEqual(ps, Platforms_1_5) {
if !reflect.DeepEqual(ps, Platforms_1_8) {
t.Fatalf("bad: %#v", ps)
}
}

func TestMIPS(t *testing.T) {
g16 := SupportedPlatforms("go1.6")
for _, p := range g16 {
if p.Arch == "mips64" && p.Default {
t.Fatal("mips64 should not be default for 1.6")
}
}

g17 := SupportedPlatforms("go1.7")
for _, p := range g17 {
if p.Arch == "mips64" && !p.Default {
t.Fatal("mips64 should be default for 1.7")
}
}

}

0 comments on commit dd49e0a

Please sign in to comment.