This repository has been archived by the owner on Oct 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 356
/
platform.go
92 lines (80 loc) · 1.98 KB
/
platform.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package main
import (
"fmt"
"strings"
)
// Platform is a combination of OS/arch that can be built against.
type Platform struct {
OS string
Arch string
// Default, if true, will be included as a default build target
// if no OS/arch is specified. We try to only set as a default popular
// targets or targets that are generally useful. For example, Android
// is not a default because it is quite rare that you're cross-compiling
// something to Android AND something like Linux.
Default bool
}
func (p *Platform) String() string {
return fmt.Sprintf("%s/%s", p.OS, p.Arch)
}
var (
OsList = []string{
"darwin",
"dragonfly",
"freebsd",
"linux",
"netbsd",
"openbsd",
"plan9",
"solaris",
"windows",
}
ArchList = []string{
"386",
"amd64",
"arm",
}
Platforms_1_0 = []Platform{
{"darwin", "386", true},
{"darwin", "amd64", true},
{"linux", "386", true},
{"linux", "amd64", true},
{"linux", "arm", true},
{"freebsd", "386", true},
{"freebsd", "amd64", true},
{"openbsd", "386", true},
{"openbsd", "amd64", true},
{"windows", "386", true},
{"windows", "amd64", true},
}
Platforms_1_1 = append(Platforms_1_0, []Platform{
{"freebsd", "arm", true},
{"netbsd", "386", true},
{"netbsd", "amd64", true},
{"netbsd", "arm", true},
{"plan9", "386", false},
}...)
Platforms_1_3 = append(Platforms_1_1, []Platform{
{"dragonfly", "386", false},
{"dragonfly", "amd64", false},
{"solaris", "amd64", false},
}...)
Platforms_1_4 = append(Platforms_1_3, []Platform{
{"plan9", "amd64", false},
}...)
)
// SupportedPlatforms returns the full list of supported platforms for
// the version of Go that is
func SupportedPlatforms(v string) []Platform {
if strings.HasPrefix(v, "go1.0") {
return Platforms_1_0
} else if strings.HasPrefix(v, "go1.1") {
return Platforms_1_1
} else if strings.HasPrefix(v, "go1.3") {
return Platforms_1_3
} else if strings.HasPrefix(v, "go1.4") {
return Platforms_1_4
}
// Assume latest
return Platforms_1_4
}