24 lines
374 B
Go
24 lines
374 B
Go
|
package browser
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"os/exec"
|
||
|
"runtime"
|
||
|
)
|
||
|
|
||
|
var commands = map[string]string{
|
||
|
"windows": "start",
|
||
|
"darwin": "open",
|
||
|
"linux": "xdg-open",
|
||
|
}
|
||
|
|
||
|
func Open(uri string) error {
|
||
|
run, ok := commands[runtime.GOOS]
|
||
|
if !ok {
|
||
|
return fmt.Errorf("don't know how to open things on %s platform", runtime.GOOS)
|
||
|
}
|
||
|
|
||
|
cmd := exec.Command(run, uri)
|
||
|
return cmd.Start()
|
||
|
}
|