X Tutup
Skip to content

Commit 8909a3e

Browse files
committed
1 parent 288d013 commit 8909a3e

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pkg/browser/browser.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,21 @@ func Command(url string) (*exec.Cmd, error) {
2020

2121
// ForOS produces an exec.Cmd to open the web browser for different OS
2222
func ForOS(goos, url string) *exec.Cmd {
23+
exe := "open"
2324
var args []string
2425
switch goos {
2526
case "darwin":
26-
args = []string{"open"}
27+
args = append(args, url)
2728
case "windows":
28-
args = []string{"cmd", "/c", "start"}
29+
exe = "cmd"
2930
r := strings.NewReplacer("&", "^&")
30-
url = r.Replace(url)
31+
args = append(args, "/c", "start", r.Replace(url))
3132
default:
32-
args = []string{"xdg-open"}
33+
exe = "xdg-open"
34+
args = append(args, url)
3335
}
3436

35-
args = append(args, url)
36-
cmd := exec.Command(args[0], args[1:]...)
37+
cmd := exec.Command(exe, args...)
3738
cmd.Stderr = os.Stderr
3839
return cmd
3940
}

0 commit comments

Comments
 (0)
X Tutup