Windows 代码实例:
package main
import (
"os/exec"
"syscall"
)
func main() {
// 有GUI调用
exec.Command(`cmd`, `/c`, `start`, `//www.greatytc.com`).Start()
// 无GUI调用
cmd := exec.Command(`cmd`, `/c`, `start`, `//www.greatytc.com`)
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
cmd.Start()
}
Linux 代码实例:
package main
import (
"os/exec"
)
func main() {
exec.Command(`xdg-open`, `//www.greatytc.com`).Start()
}
Mac 代码实例:
package main
import (
"os/exec"
)
func main() {
exec.Command(`open`, `//www.greatytc.com`).Start()
}