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.
16 # cat << EOF >> main.go
24 # fmt.Println("Hello, World!")
44 new_go_home="${HOME}/.local/opt/go-v${WEBI_VERSION}"
45 new_go="${HOME}/.local/opt/go-v${WEBI_VERSION}/bin/go"
47 # Test for existing version
49 cur_go="$(command -v go)"
51 if [ -n "$cur_go" ]; then
52 cur_ver=$(go version | cut -d' ' -f3 | sed 's:go::')
53 if [ "$cur_ver" == "$(echo $WEBI_VERSION | sed 's:\.0::g')" ]; then
54 echo "go v$WEBI_VERSION already installed at $cur_go"
56 elif [ "$cur_go" != "$new_go" ]; then
57 echo "WARN: possible conflict with go v$WEBI_VERSION at $cur_go"
62 # Note: this file is `source`d by the true installer and hence will have the webi functions
64 # because we created releases.js we can use webi_download()
65 # downloads go to ~/Downloads
68 # because this is tar or zip, we can webi_extract()
69 # extracts to the WEBI_TMP directory, raw (no --strip-prefix)
72 pushd "$WEBI_TMP" 2>&1 >/dev/null
73 echo Installing go v${WEBI_VERSION} as "$new_go"
75 # simpler for single-binary commands
76 #mv ./example*/bin/example "$HOME/.local/bin"
78 # best for packages and toolchains
80 if [ -n "$(command -v rsync 2>/dev/null | grep rsync)" ]; then
81 rsync -Krl ./go*/ "$new_go_home/" 2>/dev/null
83 cp -Hr ./go*/* "$new_go_home/" 2>/dev/null
84 cp -Hr ./go*/.* "$new_go_home/" 2>/dev/null
89 $new_go_home/bin/go get golang.org/x/tools/cmd/goimports > /dev/null 2>/dev/null
90 $new_go_home/bin/go get golang.org/x/tools/cmd/gorename > /dev/null 2>/dev/null
91 $new_go_home/bin/go get golang.org/x/tools/cmd/gotype > /dev/null 2>/dev/null
92 $new_go_home/bin/go get golang.org/x/tools/cmd/stringer > /dev/null 2>/dev/null
99 # TODO get better output from pathman / output the path to add as return to webi bootstrap
100 webi_path_add "$new_go_home/bin"
101 webi_path_add "$HOME/go/bin"
103 echo "Installed 'go' (and go tools)"