25 lines
411 B
Go
25 lines
411 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"os/exec"
|
||
|
"runtime"
|
||
|
)
|
||
|
|
||
|
func openUrl(url string) error {
|
||
|
var err error
|
||
|
|
||
|
switch runtime.GOOS {
|
||
|
case "linux":
|
||
|
err = exec.Command("xdg-open", url).Start()
|
||
|
case "windows":
|
||
|
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
|
||
|
case "darwin":
|
||
|
err = exec.Command("open", url).Start()
|
||
|
default:
|
||
|
err = fmt.Errorf("unsupported platform")
|
||
|
}
|
||
|
|
||
|
return err
|
||
|
}
|