Skip to content

Commit dccb009

Browse files
committed
Move setting browser.Stderr/Stdout to init
1 parent 13696a7 commit dccb009

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

cli/login.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ const (
2525
goosDarwin = "darwin"
2626
)
2727

28+
func init() {
29+
// Hide output from the browser library,
30+
// otherwise we can get really verbose and non-actionable messages
31+
// when in SSH or another type of headless session
32+
// NOTE: This needs to be in `init` to prevent data races
33+
// (multiple threads trying to set the global browser.Std* variables)
34+
browser.Stderr = ioutil.Discard
35+
browser.Stdout = ioutil.Discard
36+
}
37+
2838
func login() *cobra.Command {
2939
return &cobra.Command{
3040
Use: "login <url>",
@@ -223,10 +233,5 @@ func openURL(urlToOpen string) error {
223233
return exec.Command(cmd, args...).Start()
224234
}
225235

226-
// Hide output from the browser library,
227-
// otherwise we can get really verbose and non-actionable messages
228-
// when in SSH or another type of headless session
229-
browser.Stderr = ioutil.Discard
230-
browser.Stdout = ioutil.Discard
231236
return browser.OpenURL(urlToOpen)
232237
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy