Summary
Here's a bash script to Install or Update Go on OSX.update-go
#!/bin/bash
function goversion {
go version|cut -d" " -f3|while read n; do echo "${n:2}"; done
}
set -x
brew update
brew doctor
{ set +x; } &>/dev/null
echo "Current Go version: `goversion`"
echo ""
echo "Need to do what brew doctor suggested? (It's safe to rerun this command.) CTRL+C to stop --or-- Enter to continue..."
read x
if [ "`goversion`" == "" ]; then
brew install go
brew link --overwrite go
else
brew upgrade go
brew link go
fi
echo "New Go version: `goversion`"
# Following currently enables intellij Go plugin to use new Go version
function reset-idea-go-plugin {
if [ "`which idea`" != "" ]; then
printf "intellij is installed. Now, updating its go plugin..."
# Note: version numbers may change
rm /usr/local/Cellar/go/1.2.2
rm /usr/local/Cellar/go/1.3
ln -s /usr/local/Cellar/go/1.3.3 /usr/local/Cellar/go/1.2.2
echo "Done."
fi
}
reset-idea-go-plugin 2>/dev/null
Output
~ $ update-go
+ brew update
Already up-to-date.
+ brew doctor
Your system is ready to brew.
Current Go version: 1.3.3
Need to do what brew doctor suggested? (It's safe to rerun this command.) CTRL+C to stop --or-- Enter to continue...
Error: go-1.3.3 already installed
Warning: Already linked: /usr/local/Cellar/go/1.3.3
To relink: brew unlink go && brew link go
New Go version: 1.3.3
intellij is installed. Now, updating its go plugin...Done.
~ $
Notes
It's safe to rerun this script.Assumes you're on a mac.
Assumes you have homebrew installed.
If you use the Go plugin in IntelliJ, this script will direct it to use the newly installed version of Golang.
References
http://blog.jetbrains.com/idea/2010/08/quickly-create-jar-artifact/This work is licensed under the Creative Commons Attribution 3.0 Unported License.
No comments:
Post a Comment