Created
May 31, 2022 13:13
-
-
Save sattellite/b88d3e55987a576559e4aa3712bdcb8b to your computer and use it in GitHub Desktop.
Create single GOROOT on MacOS with golang installed with brew
This file contains 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 | |
src=$(go env GOROOT) | |
dst=$(brew --prefix)/Cellar/go/libexec | |
dst_link=$(readlink -f ${dst}) | |
if [ $? -ne 0 ]; then | |
echo "Create GOROOT symlink to latest go version" | |
echo "${src} -> ${dst}" | |
ln -s ${src} ${dst} | |
exit $? | |
fi | |
if [ ${dst_link} != ${src} ]; then | |
echo "Update GOROOT symlink" | |
echo "Old: ${dst_link} -> ${dst}" | |
echo "New: ${src} -> ${dst}" | |
unlink ${dst} | |
ln -s ${src} ${dst} | |
exit $? | |
fi | |
echo "GOROOT symlink is up to date" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment