-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtils.go
59 lines (51 loc) · 1.05 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"os"
"os/exec"
"runtime"
)
// From https://stackoverflow.com/a/39324149
func launchUrl(url string) error {
var cmd string
var args []string
switch runtime.GOOS {
case "windows":
cmd = "cmd"
args = []string{"/c", "start"}
case "darwin":
cmd = "open"
default: // "linux", "freebsd", "openbsd", "netbsd"
cmd = "xdg-open"
}
args = append(args, url)
proc := exec.Command(cmd, args...)
return proc.Run()
}
// From https://stackoverflow.com/a/39324149
func runGitClone(url string) error {
var cmd string
var args []string
switch runtime.GOOS {
case "windows":
cmd = "cmd"
args = []string{"/c", "git"}
case "darwin":
cmd = "git"
default: // "linux", "freebsd", "openbsd", "netbsd"
cmd = "git"
}
args = append(args, "clone", url)
proc := exec.Command(cmd, args...)
proc.Stdout = os.Stdout
proc.Stderr = os.Stderr
return proc.Run()
}
func remove(items []string, item string) []string {
var newitems []string
for _, i := range items {
if i != item {
newitems = append(newitems, i)
}
}
return newitems
}