4 # homepage: https://golang.org
5 # tagline: The Go Programming Language tools
7 # Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
15 # cat << EOF >> main.go
23 # fmt.Println("Hello, World!")
42 new_go="${HOME}/.local/opt/go-v${WEBI_VERSION}/bin/go"
43 common_go_home="${HOME}/.local/opt/go"
44 new_go_home="${HOME}/.local/opt/go-v${WEBI_VERSION}"
45 common_go_bin="${HOME}/go"
46 new_go_bin="${HOME}/.local/opt/go-bin-v${WEBI_VERSION}"
49 rm -rf "$common_go_home" # should be a symlink
50 ln -s "$new_go_home" "$common_go_home"
51 # TODO get better output from pathman / output the path to add as return to webi bootstrap
52 webi_path_add "$common_go_home/bin"
54 rm -rf "$common_go_bin"
55 mkdir -p "$new_go_bin/bin"
56 ln -s "$new_go_bin" "$common_go_bin"
57 webi_path_add "$common_go_bin/bin"
60 # Test for existing version
62 cur_go="$(command -v go)"
65 if [ -n "$cur_go" ]; then
66 cur_go_version=$(go version | cut -d' ' -f3 | sed 's:go::')
68 if [ -n "$cur_go" ]; then
69 if [ "$cur_go_version" == "$(echo $WEBI_VERSION | sed 's:\.0::g')" ]; then
70 echo "go v$WEBI_VERSION already installed at $cur_go"
73 if [ "$cur_go" != "$common_go_home/bin/go" ] && [ "$cur_go" != "$new_go" ]; then
74 echo "WARN: possible conflict between go${WEBI_VERSION} and go${cur_go_version} at ${cur_go}"
76 if [ -x "$new_go_home/bin/go" ]; then
78 echo "switched to go${WEBI_VERSION} at $new_go_home"
85 # Note: this file is `source`d by the true installer and hence will have the webi functions
87 # because we created releases.js we can use webi_download()
88 # downloads go to ~/Downloads
91 # because this is tar or zip, we can webi_extract()
92 # extracts to the WEBI_TMP directory, raw (no --strip-prefix)
95 pushd "$WEBI_TMP" 2>&1 >/dev/null
96 echo Installing go v${WEBI_VERSION} as "$new_go"
98 # simpler for single-binary commands
99 #mv ./example*/bin/example "$HOME/.local/bin"
101 # best for packages and toolchains
102 rm -rf "$new_go_home"
103 if [ -n "$(command -v rsync 2>/dev/null | grep rsync)" ]; then
104 rsync -Krl ./go*/ "$new_go_home/" 2>/dev/null
106 cp -Hr ./go*/* "$new_go_home/" 2>/dev/null
107 cp -Hr ./go*/.* "$new_go_home/" 2>/dev/null
112 $new_go_home/bin/go get golang.org/x/tools/cmd/goimports > /dev/null 2>/dev/null
113 $new_go_home/bin/go get golang.org/x/tools/cmd/gorename > /dev/null 2>/dev/null
114 $new_go_home/bin/go get golang.org/x/tools/cmd/gotype > /dev/null 2>/dev/null
115 $new_go_home/bin/go get golang.org/x/tools/cmd/stringer > /dev/null 2>/dev/null
124 echo "Installed 'go' (and go tools)"