Skip to content

Instantly share code, notes, and snippets.

@sattellite
Created May 31, 2022 13:13
Show Gist options
  • Save sattellite/b88d3e55987a576559e4aa3712bdcb8b to your computer and use it in GitHub Desktop.
Save sattellite/b88d3e55987a576559e4aa3712bdcb8b to your computer and use it in GitHub Desktop.
Create single GOROOT on MacOS with golang installed with brew
#!/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