MCPcopy
hub / github.com/pocketbase/pocketbase / LaunchURL

Function LaunchURL

tools/osutils/cmd.go:20–35  ·  view source on GitHub ↗

LaunchURL attempts to open the provided url in the user's default browser. It is platform dependent and it uses: - "open" on macOS - "rundll32" on Windows - "xdg-open" on everything else (Linux, FreeBSD, etc.)

(url string)

Source from the content-addressed store, hash-verified

18// - "rundll32" on Windows
19// - "xdg-open" on everything else (Linux, FreeBSD, etc.)
20func LaunchURL(url string) error {
21 if err := is.URL.Validate(url); err != nil {
22 return err
23 }
24
25 switch runtime.GOOS {
26 case "darwin":
27 return exec.Command("open", url).Start()
28 case "windows":
29 // not sure if this is the best command but seems to be the most reliable based on the comments in
30 // https://stackoverflow.com/questions/3739327/launching-a-website-via-the-windows-commandline#answer-49115945
31 return exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
32 default:
33 return exec.Command("xdg-open", url).Start()
34 }
35}
36
37// YesNoPrompt performs a console prompt that asks the user for Yes/No answer.
38//

Callers 1

DefaultInstallerFuncFunction · 0.92

Calls 2

ValidateMethod · 0.65
StartMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…