Skip to content

Commit 91cd860

Browse files
committed
exec-env: don't touch GO{ROOT,PATH} if ASDF_GOLANG_DISABLE_GO{ROOT,PATH} 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
1 parent 1fe10b7 commit 91cd860

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ checksum verified
8686
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).
8787
If you need to skip the checksum for some reason just set `ASDF_GOLANG_SKIP_CHECKSUM`.
8888

89+
## `GOROOT` and `GOPATH` Overrides
90+
91+
By default, `$GOROOT` and `$GOPATH` are set to the selected version's
92+
`.../go` and `.../packages` dirs, and unset if the selected version is
93+
`system`. Set the `$ASDF_GOLANG_DISABLE_GOROOT` and/or
94+
`$ASDF_GOLANG_DISABLE_GOPATH` environment variables to `1` to disable
95+
this behavior for the respective variables.
96+
8997
## Contributing
9098

9199
Feel free to create an issue or pull request if you find a bug.

bin/exec-env

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#!/usr/bin/env bash
22

33
if [ "${ASDF_INSTALL_VERSION}" = 'system' ] ; then
4-
unset -v GOROOT GOPATH
4+
[ "${ASDF_GOLANG_DISABLE_GOROOT-}" = '1' ] || unset -v GOROOT
5+
[ "${ASDF_GOLANG_DISABLE_GOPATH-}" = '1' ] || unset -v GOPATH
56
else
6-
export GOROOT=$ASDF_INSTALL_PATH/go
7-
export GOPATH=$ASDF_INSTALL_PATH/packages
7+
[ "${ASDF_GOLANG_DISABLE_GOROOT-}" = '1' ] ||
8+
export GOROOT=$ASDF_INSTALL_PATH/go
9+
[ "${ASDF_GOLANG_DISABLE_GOPATH-}" = '1' ] ||
10+
export GOPATH=$ASDF_INSTALL_PATH/packages
811
fi

0 commit comments

Comments
 (0)