MCPcopy
hub / github.com/lxc/incus / OpenBrowser

Function OpenBrowser

shared/util/browser.go:11–40  ·  view source on GitHub ↗

OpenBrowser opens the provided URL in the default web browser.

(url string)

Source from the content-addressed store, hash-verified

9
10// OpenBrowser opens the provided URL in the default web browser.
11func OpenBrowser(url string) error {
12 var err error
13
14 browser := os.Getenv("BROWSER")
15 if browser != "" {
16 if browser == "none" {
17 return nil
18 }
19
20 err = exec.Command(browser, url).Start()
21 return err
22 }
23
24 switch runtime.GOOS {
25 case "linux":
26 err = exec.Command("xdg-open", url).Start()
27 case "windows":
28 err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
29 case "darwin":
30 err = exec.Command("open", url).Start()
31 default:
32 err = errors.New("unsupported platform")
33 }
34
35 if err != nil {
36 return err
37 }
38
39 return nil
40}

Callers 2

authenticateMethod · 0.92
runMethod · 0.92

Calls 2

CommandMethod · 0.80
StartMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…