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_src, pkg_src_bin, pkg_src_cmd
47 # pkg_dst, pkg_dst_bin, pkg_dst_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 2>/dev/null | head -n 1 | cut -d' ' -f3 | sed 's:go::')"
59 pkg_format_cmd_version() {
60 # 'go v1.14.0' will be 'go1.14'
61 my_version=$(echo "$1" | sed 's:\.0::g')
62 echo "${pkg_cmd_name}${my_version}"
66 # 'pkg_dst' will default to $HOME/.local/opt/go
67 # 'pkg_src' will be the installed version, such as to $HOME/.local/opt/go-v1.14.2
69 ln -s "$pkg_src" "$pkg_dst"
71 # Go has a special $GOBIN
73 # 'GOBIN' is set above to "${HOME}/go"
74 # 'GOBIN_REAL' will be "${HOME}/.local/opt/go-bin-v${WEBI_VERSION}"
76 mkdir -p "$GOBIN_REAL/bin"
77 ln -s "$GOBIN_REAL" "$GOBIN"
81 # web_* are defined in webi/template.bash at https://github.com/webinstall/packages
83 # multiple versions may be installed
84 # if one already matches, it will simply be re-linked
87 # the download is quite large - hopefully you have wget installed
88 # will go to ~/Downloads by default
91 # Multiple formats are supported: .xz, .tar.*, and .zip
92 # will be extracted to $WEBI_TMP
97 pushd "$WEBI_TMP" 2>&1 >/dev/null
99 # remove the versioned folder, just in case it's there with junk
102 # rename the entire extracted folder to the new location
103 # (this will be "$HOME/.local/opt/go-v$WEBI_VERSION" by default)
104 mv ./"$pkg_cmd_name"* "$pkg_src"
112 # web_path_add is defined in webi/template.bash at https://github.com/webinstall/packages
114 # "$HOME/.local/opt/go"
115 webi_path_add "$pkg_dst_bin"
116 webi_path_add "$GOBIN/bin"
119 echo "Installing go extended tools (goimports, gorename, etc)"
120 "$pkg_dst_cmd" get golang.org/x/tools/cmd/goimports > /dev/null 2>/dev/null
121 "$pkg_dst_cmd" get golang.org/x/tools/cmd/gorename > /dev/null 2>/dev/null
122 "$pkg_dst_cmd" get golang.org/x/tools/cmd/gotype > /dev/null 2>/dev/null
123 "$pkg_dst_cmd" get golang.org/x/tools/cmd/stringer > /dev/null 2>/dev/null
126 pkg_post_install_message() {
127 echo "Installed 'go' (and go tools)"