blob: f95e12d7c1b25b0064f47dbb01c1231a1ccdf80a [file] [log] [blame] [view]
jbd@bc4124e2017-01-05 23:28:35 -08001# Environment Variables
2
3This page contains guides to set Go environment variables on various operating systems.
4
5## Setting GOPATH
6
7### Unix systems
8
jbd@c03fd472017-01-05 23:36:55 -08009`GOPATH` can be any directory on your system. In Unix examples, we will set it to `$HOME/work`. Note that `GOPATH` must not be the same path as your Go installation. Another common setup is to set GOPATH=$HOME.
jbd@bc4124e2017-01-05 23:28:35 -080010
11#### Bash
12
13Edit your `.bash_profile` to add the following line:
14```bash
15export GOPATH=$HOME/work
16```
17
jbd@164ffea2017-01-05 23:31:00 -080018Save and exit your editor. Then, source your `~/.bash_profile`.
jbd@bc4124e2017-01-05 23:28:35 -080019```bash
20$ source ~/.bash_profile
21```
22
jbd@edbf4f62017-01-05 23:31:18 -080023#### Zsh
jbd@164ffea2017-01-05 23:31:00 -080024
25Edit `~/.zshrc` file to add the following line:
26
27```bash
28export GOPATH=$HOME/work
29```
30Save and exit your editor. Then, source your `~/.zshrc`.
31```bash
32$ source ~/.zshrc
33```
34
jbd@bc4124e2017-01-05 23:28:35 -080035### Windows
36
37Your workspace can be located wherever you like,
38but we'll use `C:\work` in this example.
jbd@c03fd472017-01-05 23:36:55 -080039Note that `GOPATH` must not be the same path as your Go installation.
jbd@bc4124e2017-01-05 23:28:35 -080040
41* Create folder at `C:\work`.
42* Right click on "Start" and click on "Control Panel". Select "System and Security", then click on "System".
43* From the menu on the left, select the "Advanced systems settings".
44* Click the "Environment Variables button at the bottom.
45* Click "New" from the "User variables" section.
46* Type `GOPATH` into the "Variable name" field.
47* Type `C:\work` into the "Variable value" field.
48* Click OK.
49
jbd@bc4124e2017-01-05 23:28:35 -080050