Skip to content

Commit a873c21

Browse files
committed
Implement arch/os translation map for self-update
1 parent 05d373a commit a873c21

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

command_selfupdate.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ type SelfUpdateCommand struct {
1919
Force bool `long:"force" description:"force update"`
2020
}
2121

22+
var (
23+
selfUpdateOsTranslationMap = map[string]string{
24+
"darwin": "osx",
25+
}
26+
selfUpdateArchTranslationMap = map[string]string{
27+
"amd64": "x64",
28+
"386": "x32",
29+
}
30+
)
31+
2232
func (conf *SelfUpdateCommand) Execute(args []string) error {
2333
fmt.Println("Starting self update")
2434

@@ -39,18 +49,14 @@ func (conf *SelfUpdateCommand) Execute(args []string) error {
3949

4050
// translate OS names
4151
os := runtime.GOOS
42-
switch (runtime.GOOS) {
43-
case "darwin":
44-
os = "osx"
52+
if val, ok := selfUpdateOsTranslationMap[os]; ok {
53+
os = val
4554
}
4655

4756
// translate arch names
4857
arch := runtime.GOARCH
49-
switch (arch) {
50-
case "amd64":
51-
arch = "x64"
52-
case "386":
53-
arch = "x32"
58+
if val, ok := selfUpdateArchTranslationMap[arch]; ok {
59+
arch = val
5460
}
5561

5662
// build asset name

0 commit comments

Comments
 (0)