Go Install Script for macOS
Here's a simple script I use to upgrade Go on my macOS machine to the default location
/usr/local/go
. It gets the job done.
Here's a simple script I use to upgrade Go on my macOS machine to the default location
/usr/local/go
. It gets the job done.
Updates all direct dependencies of the current Go module to their latest versions.
This can be used instead of go get -u ./...
, which updates all dependencies, including transitive
dependencies. The latter may not always be desirable.
Checks for and applies all available updates to module's dependencies.
The sort -V
command is a version of the sort
utility that performs version number sorting. It
understands the logical order of version numbers, which may not always correspond to alphabetical or
numerical order.
Example:
Regular sort:
But sort -V would correctly order them as:
This is because sort -V
understands that in version numbers, 1.2 comes before 1.10.
# Lists all module dependencies (excluding the main module) by skipping the first line.
# For each dependency, explains why it's needed in the module.
go mod why -m $(go list -m all | tail -n +2)
This can be particularly useful when:
Identify which direct dependencies are pulling in various indirect dependencies.