Skip to content

Commit

Permalink
Merge pull request #24 from abhinav/resolve-before-arch
Browse files Browse the repository at this point in the history
fix: Resolve version before checking arch
  • Loading branch information
brackendawson authored Feb 9, 2024
2 parents 975cf32 + 94d20cb commit 75940b0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,18 @@ To install the previous minor release of Go:
gimme oldstable
```

To install the most recent patch of the release specified in the `go.mod` file:
To install the release specified in the `go.mod` file:

``` bash
gimme module
```

If the `go` directive in the go.mod is in the form `go 1.21`,
`gimme module` will install the latest patch version, e.g. `1.21.5`.
However, if the `go` directive in go.mod is in the form `go 1.21.3`,
`gimme module` will install the exact version, `1.21.3`.
Note that the latter form is supported only by Go 1.21 or later.

Or to install and use the development version (master branch) of Go:

``` bash
Expand Down
25 changes: 15 additions & 10 deletions gimme
Original file line number Diff line number Diff line change
Expand Up @@ -904,13 +904,26 @@ if [[ -n "${2}" ]]; then
GIMME_VERSION_PREFIX="${2}"
fi

case "${GIMME_GO_VERSION}" in
stable) GIMME_GO_VERSION=$(_get_curr_stable) ;;
oldstable) GIMME_GO_VERSION=$(_get_old_stable) ;;
module) GIMME_GO_VERSION=$(_resolve_version module) ;;
esac

_assert_version_given "$@"

case "${GIMME_ARCH}" in
x86_64) GIMME_ARCH=amd64 ;;
x86) GIMME_ARCH=386 ;;
arm64)
if [[ "${GIMME_GO_VERSION}" != master && "$(_versint "${GIMME_GO_VERSION}")" < "$(_versint 1.5)" ]]; then
min_arm64_version=1.5
if [[ "${GIMME_HOSTOS}" == 'darwin' ]]; then
min_arm64_version=1.16
fi

if [[ "${GIMME_GO_VERSION}" != master && "$(_versint "${GIMME_GO_VERSION}")" < "$(_versint "$min_arm64_version")" ]]; then
echo >&2 "error: ${GIMME_ARCH} is not supported by this go version"
echo >&2 "try go1.5 or newer"
echo >&2 "try go${min_arm64_version} or newer"
exit 1
fi
if [[ "${GIMME_HOSTOS}" == "linux" && "${GIMME_HOSTARCH}" != "${GIMME_ARCH}" ]]; then
Expand All @@ -927,14 +940,6 @@ arm64) ;;
arm*) GIMME_HOSTARCH=arm ;;
esac

case "${GIMME_GO_VERSION}" in
stable) GIMME_GO_VERSION=$(_get_curr_stable) ;;
oldstable) GIMME_GO_VERSION=$(_get_old_stable) ;;
module) GIMME_GO_VERSION=$(_resolve_version module) ;;
esac

_assert_version_given "$@"

((force_install)) && _wipe_version "${GIMME_GO_VERSION}"

unset GOARCH
Expand Down

0 comments on commit 75940b0

Please sign in to comment.