Skip to content

Commit

Permalink
feat(install/update): Use go install, allow forcing go get
Browse files Browse the repository at this point in the history
  • Loading branch information
TekWizely committed Aug 23, 2021
1 parent c63590e commit 51c3ee0
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 9 deletions.
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Bingo: The missing package manager for golang binaries<br/>(its *homebrew* for "go get")
# Bingo: The missing package manager for golang binaries<br/>(its *homebrew* for "go install")
![GitHub repo size](https://img.shields.io/github/repo-size/TekWizely/bingo)<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square)](#contributors-)<!-- ALL-CONTRIBUTORS-BADGE:END -->
![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.

Expand Down Expand Up @@ -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)
Expand All @@ -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_
```
Expand All @@ -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.

Expand Down Expand Up @@ -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:
Expand Down
38 changes: 33 additions & 5 deletions bingo
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -83,6 +97,7 @@ version:
# OPTION cmd -n,--name <name> Specify name to use for installed binary
# OPTION version --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 <package>
# USAGE (install under default name)
# USAGE <package>@<version>
Expand Down Expand Up @@ -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}"

Expand All @@ -200,8 +221,9 @@ install:
##
# Update a binary's package
#
# OPTION QUIET -q,--quiet Limit output to error messages
# OPTION version --version <version> Specify package version
# OPTION QUIET -q,--quiet Limit output to error messages
# OPTION version --version <version> Specify package version
# OPTION USE_GET --useget Use go get instead of go install
# USAGE <cmd>
# USAGE (update to latest version)
# USAGE <cmd>@<version>
Expand Down Expand Up @@ -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"

Expand Down

0 comments on commit 51c3ee0

Please sign in to comment.