app/util/util.go   A
last analyzed

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 19
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B util.OpenBrowser 0 15 6
1
package util
2
3
import (
4
	"fmt"
5
	"log"
6
	"os/exec"
7
	"runtime"
8
)
9
10
func OpenBrowser(url string) {
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