File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ package cmd
22
33import (
44 "errors"
5+ "os/exec"
6+ "runtime"
57
68 "github.com/pkg/browser"
79)
@@ -10,7 +12,24 @@ import (
1012var ErrMockBrowser = errors .New ("mock browser error" )
1113
1214// OpenURLInBrowser is exported for testing
13- var OpenURLInBrowser = browser .OpenURL
15+ var OpenURLInBrowser = openURLInBrowser
16+
17+ func openURLInBrowser (url string ) error {
18+ // On Linux, use xdg-open with output redirection to suppress messages
19+ if runtime .GOOS == "linux" {
20+ return openWithXdgOpen (url )
21+ }
22+ // For other platforms, use the default browser library
23+ return browser .OpenURL (url )
24+ }
25+
26+ func openWithXdgOpen (url string ) error {
27+ cmd := exec .Command ("xdg-open" , url )
28+ // Redirect stdout and stderr to /dev/null to suppress output
29+ cmd .Stdout = nil
30+ cmd .Stderr = nil
31+ return cmd .Start ()
32+ }
1433
1534func openURLInBrowserFunc (url string ) error {
1635 return OpenURLInBrowser (url )
You can’t perform that action at this time.
0 commit comments