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!")
39 GOBIN_REAL="${HOME}/.local/opt/go-bin-v${WEBI_VERSION}"
41 # The package is 'golang', but the command is 'go'
44 # NOTE: pkg_* variables can be defined here
46 # pkg_new_opt, pkg_new_bin, pkg_new_cmd
47 # pkg_common_opt, pkg_common_bin, pkg_common_cmd
49 # Their defaults are defined in webi/template.bash at https://github.com/webinstall/packages
51 pkg_get_current_version() {
52 # 'go version' has output in this format:
53 # go version go1.14.2 darwin/amd64
54 # This trims it down to just the version number:
56 echo "$(go version | cut -d' ' -f3 | sed 's:go::')"
59 pkg_link_new_version() {
60 # 'pkg_common_opt' will default to $HOME/.local/opt/go
61 # 'pkg_new_opt' will be the installed version, such as to $HOME/.local/opt/go-v1.14.2
62 rm -rf "$pkg_common_opt"
63 ln -s "$pkg_new_opt" "$pkg_common_opt"
65 # Go has a special $GOBIN
67 # 'GOBIN' is set above to "${HOME}/go"
68 # 'GOBIN_REAL' will be "${HOME}/.local/opt/go-bin-v${WEBI_VERSION}"
70 mkdir -p "$GOBIN_REAL"
71 ln -s "$GOBIN_REAL" "$GOBIN"
75 # web_* are defined in webi/template.bash at https://github.com/webinstall/packages
77 # multiple versions may be installed
78 # if one already matches, it will simply be re-linked
81 # the download is quite large - hopefully you have wget installed
82 # will go to ~/Downloads by default
85 # Multiple formats are supported: .xz, .tar.*, and .zip
86 # will be extracted to $WEBI_TMP
91 pushd "$WEBI_TMP" 2>&1 >/dev/null
93 # remove the versioned folder, just in case it's there with junk
96 # rename the entire extracted folder to the new location
97 # (this will be "$HOME/.local/opt/go-v$WEBI_VERSION" by default)
98 mv ./go* "$pkg_new_opt"
106 # web_path_add is defined in webi/template.bash at https://github.com/webinstall/packages
108 # "$HOME/.local/opt/go"
109 webi_path_add "$pkg_common_bin"
110 webi_path_add "$GOBIN/bin"
113 "$pkg_common_cmd" get golang.org/x/tools/cmd/goimports > /dev/null 2>/dev/null
114 "$pkg_common_cmd" get golang.org/x/tools/cmd/gorename > /dev/null 2>/dev/null
115 "$pkg_common_cmd" get golang.org/x/tools/cmd/gotype > /dev/null 2>/dev/null
116 "$pkg_common_cmd" get golang.org/x/tools/cmd/stringer > /dev/null 2>/dev/null
119 pkg_post_install_message() {
120 echo "Installed 'go' (and go tools)"