Skip to content

Commit e4cc76d

Browse files
committed
make GOOS and GOARCH gloabal vars to allow testing
1 parent d43620f commit e4cc76d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tools/download.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ var systems = map[string]string{
7373
"linuxarm": "arm-linux-gnueabihf",
7474
}
7575

76+
var (
77+
OS = runtime.GOOS
78+
Arch = runtime.GOARCH
79+
)
80+
7681
func mimeType(data []byte) (string, error) {
7782
return http.DetectContentType(data[0:512]), nil
7883
}
@@ -321,7 +326,7 @@ func findTool(pack, name, version string, data index) (tool, system) {
321326
maxSimilarity := 0.7
322327

323328
for _, s := range correctTool.Systems {
324-
similarity := smetrics.Jaro(s.Host, systems[runtime.GOOS+runtime.GOARCH])
329+
similarity := smetrics.Jaro(s.Host, systems[OS+Arch])
325330
if similarity > maxSimilarity {
326331
correctSystem = s
327332
maxSimilarity = similarity
@@ -587,7 +592,7 @@ func (t *Tools) installDrivers(location string) error {
587592
OkPressed := 6
588593
extension := ".bat"
589594
preamble := ""
590-
if runtime.GOOS != "windows" {
595+
if OS != "windows" {
591596
extension = ".sh"
592597
// add ./ to force locality
593598
preamble = "./"
@@ -599,7 +604,7 @@ func (t *Tools) installDrivers(location string) error {
599604
os.Chdir(location)
600605
t.Logger(preamble + "post_install" + extension)
601606
oscmd := exec.Command(preamble + "post_install" + extension)
602-
if runtime.GOOS != "linux" {
607+
if OS != "linux" {
603608
// spawning a shell could be the only way to let the user type his password
604609
TellCommandNotToSpawnShell(oscmd)
605610
}

0 commit comments

Comments
 (0)