gotextlog

gotextlog
git clone https://git.ryansepassi.com/git/gotextlog.git
Log | Files | Refs | README

browser.go (422B)


      1 package tui
      2 
      3 import (
      4 	"fmt"
      5 	"os/exec"
      6 	"runtime"
      7 )
      8 
      9 func openBrowser(url string) error {
     10 	var command *exec.Cmd
     11 	switch runtime.GOOS {
     12 	case "darwin":
     13 		command = exec.Command("open", url)
     14 	case "windows":
     15 		command = exec.Command("cmd", "/c", "start", "", url)
     16 	default:
     17 		command = exec.Command("xdg-open", url)
     18 	}
     19 	if err := command.Start(); err != nil {
     20 		return fmt.Errorf("open browser: %w", err)
     21 	}
     22 	return nil
     23 }