From cc5db9ba7ea3d4b636ea2870fe0a3f3decaa9177 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 31 Aug 2025 17:19:53 -0500 Subject: attempt to fix macos build --- human.go | 4 ++-- install.go | 7 +++++++ install_darwin.go | 12 ++++++++++++ install_linux.go | 36 ++++++++++++++++++++++++++++++++++++ install_windows.go | 12 ++++++++++++ linux.go | 34 ---------------------------------- 6 files changed, 69 insertions(+), 36 deletions(-) create mode 100644 install.go create mode 100644 install_darwin.go create mode 100644 install_linux.go create mode 100644 install_windows.go delete mode 100644 linux.go diff --git a/human.go b/human.go index fa7fb8c..d202673 100644 --- a/human.go +++ b/human.go @@ -14,7 +14,7 @@ func CheckProtoc() bool { userInstructions() switch runtime.GOOS { case "linux": - linuxInstall("protoc") + Install("protoc") case "macos": log.Info("todo: print instructions here for installing protoc on macos. brew install?") case "windows": @@ -32,7 +32,7 @@ func CheckProtoc() bool { userInstructions() switch runtime.GOOS { case "linux": - linuxInstall("protoc-gen-go") + Install("protoc-gen-go") case "macos": log.Info("todo: print instructions here for installing protoc on macos. brew install?") case "windows": diff --git a/install.go b/install.go new file mode 100644 index 0000000..f9199dc --- /dev/null +++ b/install.go @@ -0,0 +1,7 @@ +package fhelp + +// auto run protoc with the correct args + +func Install(pkg string) error { + return osInstall(pkg) +} diff --git a/install_darwin.go b/install_darwin.go new file mode 100644 index 0000000..ac97d4d --- /dev/null +++ b/install_darwin.go @@ -0,0 +1,12 @@ +package fhelp + +// auto run protoc with the correct args + +import ( + "go.wit.com/log" +) + +func osInstall(pkg string) error { + log.Info("todo: add instructions on macos to install", pkg) + return log.Errorf("user didn't install package %s", pkg) +} diff --git a/install_linux.go b/install_linux.go new file mode 100644 index 0000000..0ed600b --- /dev/null +++ b/install_linux.go @@ -0,0 +1,36 @@ +package fhelp + +// auto run protoc with the correct args + +import ( + "bufio" + "fmt" + "os" + "strings" + + "go.wit.com/lib/gui/shell" + "go.wit.com/log" +) + +func osInstall(pkg string) error { + cmd := []string{"apt", "install", "-y", pkg} + if pkg == "protoc" { + cmd = []string{"apt", "install", "-y", "protobuf-compiler"} + } + log.Info("Would you like to run", "sudo", cmd, "now?") + fmt.Fprintf(os.Stdout, "(y)es or (n)o ? ") + + scanner := bufio.NewScanner(os.Stdin) + for scanner.Scan() { + line := scanner.Text() + line = strings.TrimSpace(line) + line = strings.ToLower(line) + switch line { + case "y": + shell.Sudo(cmd) + return nil + default: + } + } + return log.Errorf("user didn't install package %s", pkg) +} diff --git a/install_windows.go b/install_windows.go new file mode 100644 index 0000000..3e99f01 --- /dev/null +++ b/install_windows.go @@ -0,0 +1,12 @@ +package fhelp + +// auto run protoc with the correct args + +import ( + "go.wit.com/log" +) + +func osInstall(pkg string) error { + log.Info("todo: add instructions on windows to install", pkg) + return log.Errorf("user didn't install package %s", pkg) +} diff --git a/linux.go b/linux.go deleted file mode 100644 index efdb6e8..0000000 --- a/linux.go +++ /dev/null @@ -1,34 +0,0 @@ -package fhelp - -// auto run protoc with the correct args - -import ( - "bufio" - "fmt" - "os" - "strings" - - "go.wit.com/lib/gui/shell" - "go.wit.com/log" -) - -func linuxInstall(pkg string) { - cmd := []string{"apt", "install", "-y", pkg} - if pkg == "protoc" { - cmd = []string{"apt", "install", "-y", "protobuf-compiler"} - } - log.Info("Would you like to run", "sudo", cmd, "now?") - fmt.Fprintf(os.Stdout, "(y)es or (n)o ? ") - - scanner := bufio.NewScanner(os.Stdin) - for scanner.Scan() { - line := scanner.Text() - line = strings.TrimSpace(line) - line = strings.ToLower(line) - switch line { - case "y": - shell.Sudo(cmd) - default: - } - } -} -- cgit v1.2.3