123456789101112131415161718192021222324252627 |
- package main
- import (
- "fmt"
- "log"
- "os/exec"
- "runtime"
- )
- func openURI(url string) {
- 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")
- }
- if err != nil {
- log.Fatal(err)
- }
- }
|