Skip to content

Commit f6c0b98

Browse files
committed
feat: OpenBrowser cross platform support.
1 parent c2277dd commit f6c0b98

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

pkg/browser.go

-11
This file was deleted.

pkg/open_browser_darwin.go

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//+build darwin linux
2+
3+
package pkg
4+
5+
import "fmt"
6+
7+
// OpenBrowser open url with users' operating system default web browser.
8+
// This works for MacOS.
9+
func OpenBrowser(url string) error {
10+
return Run(fmt.Sprintf("open %s", url))
11+
}

pkg/open_browser_win.go

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//+build windows
2+
3+
package pkg
4+
5+
import "fmt"
6+
7+
// OpenBrowser open url with users' operating system default web browser.
8+
// This works for windows.
9+
// https://stackoverflow.com/questions/3739327/launching-a-website-via-windows-commandline
10+
func OpenBrowser(url string) error {
11+
return Run(fmt.Sprintf("start /max %s", url))
12+
}

0 commit comments

Comments
 (0)