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 Apr 23, 2022
1 parent e23d239 commit 168b974
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ verifying checksum
checksum verified
```

## `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 168b974

Please sign in to comment.