Skip to content

Commit

Permalink
exec-env: don't touch GO{ROOT,PATH} if ASDF_GOLANG_DISABLE_GO{ROOT,PA…
Browse files Browse the repository at this point in the history
…TH} is 1

Setting these variables is not really required for things to work, and
some setups explicitly prefer them not to be touched.

Modeled after the similar options in goenv.
https://github.com/syndbg/goenv/blob/d4e2dd79b83496dbf9474e31dbdb8d7eb8bb0261/ENVIRONMENT_VARIABLES.md
  • Loading branch information
scop committed Jan 1, 2023
1 parent 1fe10b7 commit aa82aae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ selected, not necessarily `1.14.patch`.

## Architecture Override

The `ASDF_GOLANG_OVERWRITE_ARCH` variable can be used to override the architecture
that is used for determining which Go build to download. The primary use case is when attempting
The `ASDF_GOLANG_OVERWRITE_ARCH` variable can be used to override the architecture
that is used for determining which Go build to download. The primary use case is when attempting
to install an older version of Go for use on an Apple M1 computer as Go was not being built for ARM at the time.

#### Without ASDF_GOLANG_OVERWRITE_ARCH
Expand Down Expand Up @@ -86,6 +86,14 @@ checksum verified
By default we try to verify the checksum of each install but ocassionally [that's not possible](https://github.com/kennyp/asdf-golang/issues/91).
If you need to skip the checksum for some reason just set `ASDF_GOLANG_SKIP_CHECKSUM`.

## `GOROOT` and `GOPATH` Overrides

By default, `$GOROOT` and `$GOPATH` are set to the selected version's
`.../go` and `.../packages` dirs, and unset if the selected version is
`system`. Set the `$ASDF_GOLANG_DISABLE_GOROOT` and/or
`$ASDF_GOLANG_DISABLE_GOPATH` environment variables to `1` to disable
this behavior for the respective variables.

## Contributing

Feel free to create an issue or pull request if you find a bug.
Expand Down
9 changes: 6 additions & 3 deletions bin/exec-env
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/usr/bin/env bash

if [ "${ASDF_INSTALL_VERSION}" = 'system' ] ; then
unset -v GOROOT GOPATH
[ "${ASDF_GOLANG_DISABLE_GOROOT-}" = '1' ] || unset -v GOROOT
[ "${ASDF_GOLANG_DISABLE_GOPATH-}" = '1' ] || unset -v GOPATH
else
export GOROOT=$ASDF_INSTALL_PATH/go
export GOPATH=$ASDF_INSTALL_PATH/packages
[ "${ASDF_GOLANG_DISABLE_GOROOT-}" = '1' ] ||
export GOROOT=$ASDF_INSTALL_PATH/go
[ "${ASDF_GOLANG_DISABLE_GOPATH-}" = '1' ] ||
export GOPATH=$ASDF_INSTALL_PATH/packages
fi

0 comments on commit aa82aae

Please sign in to comment.