refactor to use app package instead of service
refactor app to be composable
This commit is contained in:
24
internal/utils/browser/browser.go
Normal file
24
internal/utils/browser/browser.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package browser
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
// Taken and modified from https://gist.github.com/hyg/9c4afcd91fe24316cbf0
|
||||
func Open(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
|
||||
}
|
||||
Reference in New Issue
Block a user