-
Notifications
You must be signed in to change notification settings - Fork 251
/
Copy pathINSTALL.md
161 lines (107 loc) · 6.06 KB
/
INSTALL.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# Installation
## Basic GitHub Checkout
This will get you going with the latest version of goenv and make it
easy to fork and contribute any changes back upstream.
1. **Check out goenv where you want it installed.**
A good place to choose is `$HOME/.goenv` (but you can install it somewhere else).
git clone https://github.com/syndbg/goenv.git ~/.goenv
2. **Define environment variable `GOENV_ROOT`** to point to the path where
goenv repo is cloned and add `$GOENV_ROOT/bin` to your `$PATH` for access
to the `goenv` command-line utility.
echo 'export GOENV_ROOT="$HOME/.goenv"' >> ~/.bash_profile
echo 'export PATH="$GOENV_ROOT/bin:$PATH"' >> ~/.bash_profile
**Zsh note**: Modify your `~/.zshenv` file instead of `~/.bash_profile`.
**Ubuntu note**: Modify your `~/.bashrc` file instead of `~/.bash_profile`.
3. **Add `goenv init` to your shell** to enable shims, management of `GOPATH` and `GOROOT` and auto-completion.
Please make sure `eval "$(goenv init -)"` is placed toward the end of the shell
configuration file since it manipulates `PATH` during the initialization.
echo 'eval "$(goenv init -)"' >> ~/.bash_profile
**Zsh note**: Modify your `~/.zshenv` or `~/.zshrc` file instead of `~/.bash_profile`.
**Ubuntu note**: Modify your `~/.bashrc` file instead of `~/.bash_profile`.
**General warning**: There are some systems where the `BASH_ENV` variable is configured
to point to `.bashrc`. On such systems you should almost certainly put the abovementioned line
`eval "$(goenv init -)` into `.bash_profile`, and **not** into `.bashrc`. Otherwise you
may observe strange behaviour, such as `goenv` getting into an infinite loop.
See pyenv's issue [#264](https://github.com/yyuu/pyenv/issues/264) for details.
4. **If you want `goenv` to manage `GOPATH` and `GOROOT` (recommended)**,
add `GOPATH` and `GOROOT` to your shell **after `eval "$(goenv init -)"`**.
echo 'export PATH="$GOROOT/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="$PATH:$GOPATH/bin"' >> ~/.bash_profile
**Zsh note**: Modify your `~/.zshenv` or `~/.zshrc` file instead of `~/.bash_profile`.
**Ubuntu note**: Modify your `~/.bashrc` file instead of `~/.bash_profile`.
**General warning**: There are some systems where the `BASH_ENV` variable is configured
to point to `.bashrc`. On such systems you should almost certainly put the abovementioned line
`eval "$(goenv init -)` into `.bash_profile`, and **not** into `.bashrc`. Otherwise you
may observe strange behaviour, such as `goenv` getting into an infinite loop.
See pyenv's issue [#264](https://github.com/yyuu/pyenv/issues/264) for details.
**Security warning**: You likely want to keep $GOPATH/bin at the end
of your $PATH as shown above, rather than at the beginning. See
[#99](https://github.com/syndbg/goenv/issues/99) for details and
discussion.
5. **Restart your shell so the path changes take effect.**
You can now begin using goenv.
exec $SHELL
6. **Install Go versions into `$GOENV_ROOT/versions`.**
For example, to download and install Go 1.12.0, run:
goenv install 1.12.0
**NOTE:** It downloads and places the prebuilt Go binaries provided by Google.
An example `.zshrc` that is properly configured may look like
```shell
export GOENV_ROOT="$HOME/.goenv"
export PATH="$GOENV_ROOT/bin:$PATH"
eval "$(goenv init -)"
export PATH="$GOROOT/bin:$PATH"
export PATH="$PATH:$GOPATH/bin"
```
## via ZPlug plugin manager for Zsh
Add the following line to your `.zshrc`:
```zplug "RiverGlide/zsh-goenv", from:gitlab```
Then install the plugin
~~~ zsh
source ~/.zshrc
zplug install
~~~
The ZPlug plugin will install and initialise `goenv` and add `goenv` and `goenv-install` to your `PATH`
## Homebrew on Mac OS X
You can also install goenv using the [Homebrew](http://brew.sh)
package manager for Mac OS X.
brew update
brew install goenv
To upgrade goenv in the future, use `upgrade` instead of `install`.
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.
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").
## Upgrading
If you've installed goenv using the instructions above, you can
upgrade your installation at any time using git.
To upgrade to the latest development version of goenv, use `git pull`:
cd ~/.goenv && git fetch --all && git pull
To upgrade to a specific release of goenv, check out the corresponding tag:
cd ~/.goenv
git fetch --all
git tag
v20160417
git checkout v20160417
## Uninstalling goenv
The simplicity of goenv makes it easy to temporarily disable it, or
uninstall from the system.
1. To **disable** goenv managing your Go versions, simply remove the
`goenv init` line from your shell startup configuration. This will
remove goenv shims directory from PATH, and future invocations like
`goenv` will execute the system Go version, as before goenv.
`goenv` will still be accessible on the command line, but your Go
apps won't be affected by version switching.
2. To completely **uninstall** goenv, perform step (1) and then remove
its root directory. This will **delete all Go versions** that were
installed under `` `goenv root`/versions/ `` directory:
rm -rf `goenv root`
If you've installed goenv using a package manager, as a final step
perform the goenv package removal. For instance, for Homebrew:
brew uninstall goenv
## Uninstalling Go Versions
As time goes on, you will accumulate Go versions in your
`~/.goenv/versions` directory.
To remove old Go versions, `goenv uninstall` command to automate
the removal process.
Alternatively, simply `rm -rf` the directory of the version you want
to remove. You can find the directory of a particular Go version
with the `goenv prefix` command, e.g. `goenv prefix 1.6.2`.