forked from nickalie/go-binwrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.go
45 lines (36 loc) · 852 Bytes
/
utils.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
package binwrapper
import (
"runtime"
)
func osFilterObj(values []*Src) *Src {
arches := []string{runtime.GOARCH}
if runtime.GOARCH == "386" {
arches = append(arches,"x86")
} else if runtime.GOARCH == "amd64" {
arches = append(arches,"x64")
}
platforms := []string{runtime.GOOS}
if runtime.GOOS == "windows" {
platforms = append(platforms,"win32")
}
for _, v := range values {
if stringsContains(platforms, v.os) && stringsContains(arches, v.arch) {
return v
} else if stringsContains(platforms, v.os) && v.arch == "" {
return v
} else if stringsContains(arches, v.arch) && v.os == "" {
return v
} else if v.os == "" && v.arch == "" {
return v
}
}
return nil
}
func stringsContains(values []string, value string) bool {
for _, v := range values {
if v == value {
return true
}
}
return false
}