Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Resolve version before checking arch #24

Merged
merged 3 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading