From 183ba921c26680f25ea2cb19064c12f1b746b6ec Mon Sep 17 00:00:00 2001 From: jolheiser Date: Sun, 8 Aug 2021 23:09:05 -0500 Subject: [PATCH] Better OS check Signed-off-by: jolheiser --- cmd/godl/{godl.go => main.go} | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename cmd/godl/{godl.go => main.go} (93%) diff --git a/cmd/godl/godl.go b/cmd/godl/main.go similarity index 93% rename from cmd/godl/godl.go rename to cmd/godl/main.go index 6ed5a85..5a50cec 100644 --- a/cmd/godl/godl.go +++ b/cmd/godl/main.go @@ -2,7 +2,6 @@ package main import ( "context" - "errors" "flag" "fmt" "io" @@ -18,9 +17,14 @@ import ( "github.com/schollz/progressbar/v3" ) +var f = false + func main() { downloadFlag := flag.Bool("download", false, "Download latest Go") - installFlag := flag.Bool("install", false, "Install/Update Go (Linux only)") + installFlag := &f + if runtime.GOOS == "linux" { + installFlag = flag.Bool("install", false, "Install/Update Go") + } outFlag := flag.String("out", ".", "Where to put the downloaded file") flag.Parse() @@ -128,10 +132,6 @@ func download(filename, outPath string) error { } func install(outPath string) error { - if !strings.EqualFold(runtime.GOOS, "linux") { - return errors.New("Install option is only for Linux. Mac and Windows users should run the downloaded installer.") - } - if os.Geteuid() != 0 { return fmt.Errorf(`This command must be run as root to perform the install. Alternatively, you can run the following command manually, which is taken from https://golang.org/doc/install#install