Created
November 22, 2024 04:16
-
-
Save tbxark/2346221d5534e03ea341f0d854d51f71 to your computer and use it in GitHub Desktop.
Update go bin to the latest version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| if [[ -z "$GOPATH" ]]; then | |
| export GOPATH=~/go | |
| fi | |
| for bin in $GOPATH/bin/*; do | |
| if [[ -x "$bin" ]]; then | |
| path=$(go version -m "$bin" | grep "^[[:space:]]*path" | awk '{print $2}') | |
| if [[ "$path" == */* ]]; then | |
| echo "Updating $bin from $path" | |
| go install "$path@latest" | |
| else | |
| echo "$bin is not installed from a remote path." | |
| fi | |
| else | |
| echo "$bin is not executable." | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment