|
| 1 | +# Installation |
| 2 | + |
| 3 | +## Basic GitHub Checkout |
| 4 | + |
| 5 | +This will get you going with the latest version of goenv and make it |
| 6 | +easy to fork and contribute any changes back upstream. |
| 7 | + |
| 8 | +1. **Check out goenv where you want it installed.** |
| 9 | + A good place to choose is `$HOME/.goenv` (but you can install it somewhere else). |
| 10 | + |
| 11 | + $ git clone https://github.com/syndbg/goenv.git ~/.goenv |
| 12 | + |
| 13 | + |
| 14 | +2. **Define environment variable `GOENV_ROOT`** to point to the path where |
| 15 | + goenv repo is cloned and add `$GOENV_ROOT/bin` to your `$PATH` for access |
| 16 | + to the `goenv` command-line utility. |
| 17 | + |
| 18 | + $ echo 'export GOENV_ROOT="$HOME/.goenv"' >> ~/.bash_profile |
| 19 | + $ echo 'export PATH="$GOENV_ROOT/bin:$PATH"' >> ~/.bash_profile |
| 20 | + |
| 21 | + **Zsh note**: Modify your `~/.zshenv` file instead of `~/.bash_profile`. |
| 22 | + **Ubuntu note**: Modify your `~/.bashrc` file instead of `~/.bash_profile`. |
| 23 | + |
| 24 | +3. **Add `goenv init` to your shell** to enable shims and autocompletion. |
| 25 | + Please make sure `eval "$(goenv init -)"` is placed toward the end of the shell |
| 26 | + configuration file since it manipulates `PATH` during the initialization. |
| 27 | + |
| 28 | + $ echo 'eval "$(goenv init -)"' >> ~/.bash_profile |
| 29 | + |
| 30 | + **Zsh note**: Modify your `~/.zshenv` file instead of `~/.bash_profile`. |
| 31 | + **Ubuntu note**: Modify your `~/.bashrc` file instead of `~/.bash_profile`. |
| 32 | + |
| 33 | + **General warning**: There are some systems where the `BASH_ENV` variable is configured |
| 34 | + to point to `.bashrc`. On such systems you should almost certainly put the abovementioned line |
| 35 | + `eval "$(goenv init -)` into `.bash_profile`, and **not** into `.bashrc`. Otherwise you |
| 36 | + may observe strange behaviour, such as `goenv` getting into an infinite loop. |
| 37 | + See pyenv's issue [#264](https://github.com/yyuu/pyenv/issues/264) for details. |
| 38 | + |
| 39 | +4. **Restart your shell so the path changes take effect.** |
| 40 | + You can now begin using goenv. |
| 41 | + |
| 42 | + $ exec $SHELL |
| 43 | + |
| 44 | +5. **Install Go versions into `$GOENV_ROOT/versions`.** |
| 45 | + For example, to download and install Go 1.6.2, run: |
| 46 | + |
| 47 | + $ goenv install 1.6.2 |
| 48 | + |
| 49 | + **NOTE:** It downloads and places the prebuilt Go binaries provided by Google. |
| 50 | + |
| 51 | +## Homebrew on Mac OS X |
| 52 | + |
| 53 | +You can also install goenv using the [Homebrew](http://brew.sh) |
| 54 | +package manager for Mac OS X. |
| 55 | + |
| 56 | + $ brew update |
| 57 | + $ brew install goenv |
| 58 | + |
| 59 | +To upgrade goenv in the future, use `upgrade` instead of `install`. |
| 60 | + |
| 61 | +After installation, you'll need to add `eval "$(goenv init -)"` to your profile (as stated in the caveats displayed by Homebrew — to display them again, use `brew info goenv`). You only need to add that to your profile once. |
| 62 | + |
| 63 | +Then follow the rest of the post-installation steps under "Basic GitHub Checkout" above, starting with #4 ("restart your shell so the path changes take effect"). |
| 64 | + |
| 65 | +## Upgrading |
| 66 | + |
| 67 | +If you've installed goenv using the instructions above, you can |
| 68 | +upgrade your installation at any time using git. |
| 69 | + |
| 70 | +To upgrade to the latest development version of goenv, use `git pull`: |
| 71 | + |
| 72 | + $ cd ~/.goenv |
| 73 | + $ git pull |
| 74 | + |
| 75 | +To upgrade to a specific release of goenv, check out the corresponding tag: |
| 76 | + |
| 77 | + $ cd ~/.goenv |
| 78 | + $ git fetch |
| 79 | + $ git tag |
| 80 | + v20160417 |
| 81 | + $ git checkout v20160417 |
| 82 | + |
| 83 | +## Uninstalling goenv |
| 84 | + |
| 85 | +The simplicity of goenv makes it easy to temporarily disable it, or |
| 86 | +uninstall from the system. |
| 87 | + |
| 88 | +1. To **disable** goenv managing your Go versions, simply remove the |
| 89 | + `goenv init` line from your shell startup configuration. This will |
| 90 | + remove goenv shims directory from PATH, and future invocations like |
| 91 | + `goenv` will execute the system Go version, as before goenv. |
| 92 | + |
| 93 | + `goenv` will still be accessible on the command line, but your Go |
| 94 | + apps won't be affected by version switching. |
| 95 | + |
| 96 | +2. To completely **uninstall** goenv, perform step (1) and then remove |
| 97 | + its root directory. This will **delete all Go versions** that were |
| 98 | + installed under `` `goenv root`/versions/ `` directory: |
| 99 | + |
| 100 | + rm -rf `goenv root` |
| 101 | + |
| 102 | + If you've installed goenv using a package manager, as a final step |
| 103 | + perform the goenv package removal. For instance, for Homebrew: |
| 104 | + |
| 105 | + brew uninstall goenv |
| 106 | + |
| 107 | +## Uninstalling Go Versions |
| 108 | + |
| 109 | +As time goes on, you will accumulate Go versions in your |
| 110 | +`~/.goenv/versions` directory. |
| 111 | + |
| 112 | +To remove old Go versions, `goenv uninstall` command to automate |
| 113 | +the removal process. |
| 114 | + |
| 115 | +Alternatively, simply `rm -rf` the directory of the version you want |
| 116 | +to remove. You can find the directory of a particular Go version |
| 117 | +with the `goenv prefix` command, e.g. `goenv prefix 1.6.2`. |
0 commit comments