From 51c3ee0837041bf3057e255ba5a165e7fd011ae8 Mon Sep 17 00:00:00 2001 From: "TekWize.ly" Date: Mon, 23 Aug 2021 10:17:17 -0700 Subject: [PATCH] feat(install/update): Use go install, allow forcing go get --- README.md | 27 +++++++++++++++++++++++---- bingo | 38 +++++++++++++++++++++++++++++++++----- 2 files changed, 56 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 9cf8517..cb71f8e 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -# Bingo: The missing package manager for golang binaries
(its *homebrew* for "go get") +# Bingo: The missing package manager for golang binaries
(its *homebrew* for "go install") ![GitHub repo size](https://img.shields.io/github/repo-size/TekWizely/bingo) [![All Contributors](https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square)](#contributors-) ![GitHub stars](https://img.shields.io/github/stars/TekWizely/bingo?style=social) ![GitHub forks](https://img.shields.io/github/forks/TekWizely/bingo?style=social) ![Twitter Follow](https://img.shields.io/twitter/follow/TekWizely?style=social) -Do you love the simplicity of being able to download & compile golang applications with `'go get'`, but wish it were easier to manage the compiled binaries? +Do you love the simplicity of being able to download & compile golang applications with `'go install'`, but wish it were easier to manage the compiled binaries? Bingo makes installing and managing golang-compiled binaries a bit easier. @@ -33,6 +33,7 @@ Bingo makes installing and managing golang-compiled binaries a bit easier. - [Compiling 'Complicated' Packages](#compiling-complicated-packages) - [Specifying Package Version](#specifying-package-version) - [Binary Naming](#binary-naming) + - [Using Go Get](#using-go-get) - [Listing Installed Binaries](#listing-installed-binaries) - [Displaying A Binary's Associated Package](#displaying-a-binarys-associated-package) - [Updating Binaries](#updating-binaries) @@ -41,7 +42,7 @@ Bingo makes installing and managing golang-compiled binaries a bit easier. ------------------------------------ #### Compiling + Installing Binaries -To install a binary with bingo, use the golang application's full package path, same as you would with `"go get"`. +To install a binary with bingo, use the golang application's full package path, same as you would with `"go install"`. _hello example_ ``` @@ -62,7 +63,7 @@ Hello, Go examples! ##### Compiling 'Complicated' Packages *TBD* -Currently, bingo only supports packages which can be directly compiled via `go get`. +Currently, bingo only supports packages which can be directly downloaded + compiled + installed via `go install` (or [go get](#using-go-get) for pre v1.16). Packages that require a more complex build process are not supported at this time. @@ -105,6 +106,24 @@ $ ~/.bingo/bin/foo Hello, Go examples! ``` +##### Using Go Get + +By default, bingo uses `go install` to download + compile + install packages. + +If you're using a version of go prior to v1.16, you can instruct bingo to use `go get`: + +_install example using --useget option_ +``` +$ bingo install --useget github.com/golang/example/hello +``` + +_install example using BINGO_USE_GET variable_ +``` +$ BINGO_USE_GET=1 bingo install github.com/golang/example/hello +``` + +**NOTE:** Both of these work for the `bingo update` command as well. + #### Listing Installed Binaries To see a list of installed binaries, use the `installed` command: diff --git a/bingo b/bingo index d4efe54..93aa3bf 100755 --- a/bingo +++ b/bingo @@ -1,6 +1,6 @@ #!/usr/bin/env run shebang -BINGO_VERSION="0.2.0" +BINGO_VERSION="0.3.0" # ############################################################################## # # BINGO - The missing package manager for golang binaries @@ -52,6 +52,20 @@ BINGO_VERSION="0.2.0" # $HOME/.bingo/pkg # $HOME/.bingo/cache # +# Forcing go get +# +# By default, bingo uses `go install` to download + install packages. +# If you're using a version of go prior to v1.16, you can instruct bingo +# to use `go get`: +# +# Via command-line: +# +# bingo install --useget ... +# +# Via environment variable: +# +# BINGO_USE_GET=1 bingo install ... +# # License # # The bingo project is released under the MIT License: @@ -83,6 +97,7 @@ version: # OPTION cmd -n,--name Specify name to use for installed binary # OPTION version --version Specify package version # OPTION QUIET -q,--quiet Limit output to error messages +# OPTION USE_GET --useget Use go get instead of go install # USAGE # USAGE (install under default name) # USAGE @ @@ -175,7 +190,13 @@ install: [ -z "${QUIET}" ] && echo "Installing binary ${cmd} from package ${pkg}${version:+@$version}" [ -z "${QUIET}" ] && echo "Downloading & compiling package (folder: '${PKG_ROOT}')" - go get "${VERBOSE:+-v}" "${pkg}${version:+@$version}" + + INSTALL="install" + if [ -n "${BINGO_USE_GET}" -o -n "${USE_GET}" ]; then + INSTALL="get" + [ -z "${QUIET}" ] && echo "Using 'go get' instead of 'go install'" + fi + go "${INSTALL}" "${VERBOSE:+-v}" "${pkg}${version:+@$version}" PKG_CMD="${GOBIN}/${pkgbin}" @@ -200,8 +221,9 @@ install: ## # Update a binary's package # -# OPTION QUIET -q,--quiet Limit output to error messages -# OPTION version --version Specify package version +# OPTION QUIET -q,--quiet Limit output to error messages +# OPTION version --version Specify package version +# OPTION USE_GET --useget Use go get instead of go install # USAGE # USAGE (update to latest version) # USAGE @ @@ -280,7 +302,13 @@ update: [ -z "${QUIET}" ] && VERBOSE="1" [ -z "${QUIET}" ] && echo "Updating ${cmd} package ${pkg}${version:+ to $version}" - go get "${VERBOSE:+-v}" "${pkg}${version:+@$version}" + + INSTALL="install" + if [ -n "${BINGO_USE_GET}" -o -n "${USE_GET}" ]; then + INSTALL="get" + [ -z "${QUIET}" ] && echo "Using 'go get' instead of 'go install'" + fi + go "${INSTALL}" "${VERBOSE:+-v}" "${pkg}${version:+@$version}" [ -z "${QUIET}" ] && echo "Done"