Skip to content

Commit aa67f4c

Browse files
Update INSTALL.md with automatic version detection documentation
Co-authored-by: ChronosMasterOfAllTime <28963807+ChronosMasterOfAllTime@users.noreply.github.com>
1 parent 4db0700 commit aa67f4c

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

INSTALL.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,22 @@ export GOENV_ROOT="$HOME/.goenv"
6262
export PATH="$GOENV_ROOT/bin:$PATH"
6363
eval "$(goenv init -)"
6464
```
65+
66+
7. **(Optional) Enable automatic version detection on directory change.**
67+
By default, when you `cd` into a directory with a `.go-version` file, the shims will use the correct Go version,
68+
but environment variables like `GOROOT` and `GOPATH` won't update until you reload your shell.
69+
70+
To enable automatic updating of `GOROOT` and `GOPATH` when changing directories, set the following environment variable:
71+
72+
```shell
73+
export GOENV_AUTOMATICALLY_DETECT_VERSION=1
74+
```
75+
76+
Add this line **before** the `eval "$(goenv init -)"` line in your shell configuration file.
77+
78+
**Note:** This feature adds a hook that runs on every directory change (or before each prompt in bash/ksh),
79+
which may have a slight performance impact. If you don't need `GOROOT` and `GOPATH` to update automatically,
80+
you can leave this disabled and rely on the shims, which always work correctly.
6581

6682
## via ZPlug plugin manager for Zsh
6783

0 commit comments

Comments
 (0)