browser: simplify API
The context is doing nothing here.
diff --git a/browser/browser.go b/browser/browser.go
index f6e1443..5032633 100644
--- a/browser/browser.go
+++ b/browser/browser.go
@@ -2,7 +2,6 @@
package browser
import (
- "context"
"fmt"
"os"
"os/exec"
@@ -14,15 +13,15 @@
// - 'open' for macOS
// - 'cmd /c start' for Windows
// - 'xdg-open' for Linux and other Unix-like systems
-func Open(ctx context.Context, url string) {
+func Open(url string) {
var cmd *exec.Cmd
switch runtime.GOOS {
case "darwin":
- cmd = exec.CommandContext(ctx, "open", url)
+ cmd = exec.Command("open", url)
case "windows":
- cmd = exec.CommandContext(ctx, "cmd", "/c", "start", url)
+ cmd = exec.Command("cmd", "/c", "start", url)
default: // Linux and other Unix-like systems
- cmd = exec.CommandContext(ctx, "xdg-open", url)
+ cmd = exec.Command("xdg-open", url)
}
if b, err := cmd.CombinedOutput(); err != nil {
fmt.Fprintf(os.Stderr, "failed to open browser: %v: %s\n", err, b)
diff --git a/cmd/sketch/main.go b/cmd/sketch/main.go
index cb0cee6..081f7ca 100644
--- a/cmd/sketch/main.go
+++ b/cmd/sketch/main.go
@@ -308,7 +308,7 @@
// Open the web UI URL in the system browser if requested
if *openBrowser {
- browser.Open(ctx, ps1URL)
+ browser.Open(ps1URL)
}
// Create the termui instance
diff --git a/dockerimg/dockerimg.go b/dockerimg/dockerimg.go
index 03fc400..baaf506 100644
--- a/dockerimg/dockerimg.go
+++ b/dockerimg/dockerimg.go
@@ -311,9 +311,9 @@
// We open the browser after the init config because the above waits for the web server to be serving.
if config.OpenBrowser {
if config.SkabandAddr != "" {
- browser.Open(ctx, fmt.Sprintf("%s/s/%s", config.SkabandAddr, config.SessionID))
+ browser.Open(fmt.Sprintf("%s/s/%s", config.SkabandAddr, config.SessionID))
} else {
- browser.Open(ctx, "http://"+localAddr)
+ browser.Open("http://" + localAddr)
}
}
}()