Skip to content

Commit

Permalink
feat: support new go install command
Browse files Browse the repository at this point in the history
Signed-off-by: Yasunori Fujie <fujie@ai2-jp.com>
  • Loading branch information
yacchi committed Aug 18, 2021
1 parent 9cf9198 commit c73bf7a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ func main() {
}

switch os.Args[1] {
case "version":
fmt.Println(strings.TrimLeft(runtime.Version(), "go"))
case "sdk-path":
printSDKPath()
case "gopath":
Expand Down
13 changes: 11 additions & 2 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,19 @@ install_version() {
return
fi

# go version of semver (e.g. 1.16.3) to shell comparable string (e.g 011603)
local go_comparable_version=
go_comparable_version=$(go_plugin_tool version | awk -F . '{printf "%2d%02d%02d", $1, $2, $3}')

(
# Download go${version} into $GOPATH/bin
echo go get "${DOWNLOAD_URL}/go${version}"
go_cmd get "${DOWNLOAD_URL}/go${version}"
if [[ ${go_comparable_version} -ge 11700 ]]; then
echo go install "${DOWNLOAD_URL}/go${version}@latest"
go_cmd install "${DOWNLOAD_URL}/go${version}@latest"
else
echo go get "${DOWNLOAD_URL}/go${version}"
go_cmd get "${DOWNLOAD_URL}/go${version}"
fi

# Download Go SDK into GOROOT
local go_bin
Expand Down

0 comments on commit c73bf7a

Please sign in to comment.