go-global-update
go-global-update copied to clipboard
A command to update globally installed go executables
go-global-update
Update globally installed go binaries.
The missing go command similar to npm -g update
or
cargo install-update.
Table of contents
- Requirements
- Installation
- Usage
-
Upgrading
go-global-update
- Troubleshooting
- How it works
- Alternative tools
- Contributing
Requirements
- Go 1.16 or higher
Installation
go install github.com/Gelio/go-global-update@latest
Usage
Running
go-global-update
will print information about currently installed global binaries and attempt to upgrade those that have newer versions.
You can also do a dry run without update the binaries:
go-global-update --dry-run
or update just a handful of binaries:
go-global-update gofumpt
For more information, see
go-global-update --help
Upgrading go-global-update
go-global-update
will take care of updating itself when it updates other
binaries.
Troubleshooting
Do you have problems updating some binaries using go-global-update
? Take a
look at TROUBLESHOOTING.md for more information.
How it works
go-global-update
consists of the following steps:
-
Determine binaries to inspect.
Either use the list of provided arguments or all executables installed in your
go env GOBIN
(or$(go env GOPATH)/bin
). -
Inspect where each executable came from (by running
go version -m [executable name]
and checking thepath
), -
Check the latest version for each binary using
go list -m -f "{{.Version}}" [path]
-
If the binary has a newer version, run
go install [package path]@latest
to update it.
Alternative tools
go-global-update
is not the only tool trying to solve the problem of updating
globally-installed go binaries. The alternatives are:
-
Advantages:
- includes desktop notifications
- has a subcommand to remove a binary
- has a way to export/import a list of binaries
Disadvantages:
- does not offer troubleshooting information when an upgrade fails
- does not report error logs from failed updates
- updates binaries installed from source (potentially overwrites locally-made changes)
-
Disadvantages:
-
seems not to detect globally-installed binaries using go modules
$ binstale binstale (no source package found) go-global-update stale: github.com/Gelio/go-global-update (stale dependency: github.com/Gelio/go-global-update/internal/colors) gofumpt (no source package found) gotop (no source package found) misspell (no source package found) shfmt
-
Contributing
Contributions are welcome! See CONTRIBUTING.md for more information.