MCPcopy Create free account
hub / github.com/exercism/cli / Open

Function Open

browser/open.go:11–32  ·  view source on GitHub ↗

Open opens a browser to the given URL. The terminal's open command is operating system dependent.

(url string)

Source from the content-addressed store, hash-verified

9// Open opens a browser to the given URL.
10// The terminal's open command is operating system dependent.
11func Open(url string) error {
12 // Escape characters are not allowed by cmd/bash.
13 switch runtime.GOOS {
14 case "windows":
15 url = strings.Replace(url, "&", `^&`, -1)
16 default:
17 url = strings.Replace(url, "&", `\&`, -1)
18 }
19
20 // The command to open the browser is OS-dependent.
21 var cmd *exec.Cmd
22 switch runtime.GOOS {
23 case "darwin":
24 cmd = exec.Command("open", url)
25 case "freebsd", "linux", "netbsd", "openbsd":
26 cmd = exec.Command("xdg-open", url)
27 case "windows":
28 cmd = exec.Command("cmd", "/c", "start", url)
29 }
30
31 return cmd.Run()
32}

Callers 1

open.goFile · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected