-
Notifications
You must be signed in to change notification settings - Fork 28
/
util.go
54 lines (49 loc) · 1.33 KB
/
util.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
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package build
// SetFromGoArch assigns the GOARCH string label to x. In particular,
// it takes care of mapping "386" to "x86" as the former is not a
// valid VDL enum value.
func (x *Architecture) SetFromGoArch(label string) error {
switch label {
case "386":
return x.Set("x86")
default:
return x.Set(label)
}
}
// SetFromGoOS assigns the GOOS string label to x.
func (x *OperatingSystem) SetFromGoOS(label string) error {
return x.Set(label)
}
// ToGoArch returns a GOARCH string label for the given Architecture.
// In particular, it takes care of mapping "x86" to "386" as the latter
// is not a valid VDL enum value.
func (arch Architecture) ToGoArch() string {
switch arch {
case ArchitectureAmd64:
return "amd64"
case ArchitectureArm:
return "arm"
case ArchitectureX86:
return "386"
default:
return "unknown"
}
}
// ToGoOS returns a GOOS string label for the given Architecture.
func (os OperatingSystem) ToGoOS() string {
switch os {
case OperatingSystemDarwin:
return "darwin"
case OperatingSystemLinux:
return "linux"
case OperatingSystemWindows:
return "windows"
case OperatingSystemAndroid:
return "android"
default:
return "unknown"
}
}