1 Star 0 Fork 0

白菜林/go-util

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
open_url.go 449 Bytes
一键复制 编辑 原始数据 按行查看 历史
白菜林 提交于 2023-04-18 00:55 . debug
package util
import (
"os/exec"
"runtime"
)
// open opens the specified URL in the default browser of the user.
func OpenURL(url string) error {
var cmd string
var args []string
switch runtime.GOOS {
case "windows":
cmd = "cmd"
args = []string{"/c", "start"}
case "darwin":
cmd = "open"
default: // "linux", "freebsd", "openbsd", "netbsd"
cmd = "xdg-open"
}
args = append(args, url)
return exec.Command(cmd, args...).Start()
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/lyhuilin/util.git
git@gitee.com:lyhuilin/util.git
lyhuilin
util
go-util
v0.2.10

搜索帮助