Passed
Push — master ( 7456e0...8eb6db )
by Stanislav
01:27
created

util.OpenBrowser   B

Complexity

Conditions 6

Size

Total Lines 15
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
dl 0
loc 15
rs 8.6666
c 0
b 0
f 0
eloc 13
nop 1
1
package util
2
3
import (
4
	"runtime"
5
	"os/exec"
6
	"fmt"
7
	"log"
8
)
9
10
func OpenBrowser(url string) {
0 ignored issues
show
introduced by
exported function OpenBrowser should have comment or be unexported
Loading history...
11
	var err error
12
13
	switch runtime.GOOS {
14
	case "linux":
15
		err = exec.Command("xdg-open", url).Start()
16
	case "windows":
17
		err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
18
	case "darwin":
19
		err = exec.Command("open", url).Start()
20
	default:
21
		err = fmt.Errorf("unsupported platform")
22
	}
23
	if err != nil {
24
		log.Fatal(err)
25
	}
26
}
27