blob: 68e904797e76b1e41b827cb49a39e075205b4370 [file] [log] [blame] [view]
kim yongbin234fa292017-01-09 22:48:13 +09001The GOPATH environment variable specifies the location of your workspace. By default it is `$HOME/go` on Unix systems and `%USERPROFILE%\go` on Windows. If you want to use a custom location as your workspace, you can set the GOPATH env variable. This page explains how to set this variable on various platforms.
jbd@8858ce62017-01-06 17:21:05 -08002
3
jbd@479e84a2017-01-06 17:18:01 -08004- [Unix systems](#unix-systems)
5 * [Bash](#bash)
6 * [Zsh](#zsh)
7- [Windows](#windows)
8
jbd@fab88312017-01-06 17:17:16 -08009# Unix systems
jbd@bc4124e2017-01-05 23:28:35 -080010
jbd@c03fd472017-01-05 23:36:55 -080011`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 -080012
jbd@fab88312017-01-06 17:17:16 -080013## Bash
jbd@bc4124e2017-01-05 23:28:35 -080014
15Edit your `.bash_profile` to add the following line:
16```bash
17export GOPATH=$HOME/work
18```
19
jbd@164ffea2017-01-05 23:31:00 -080020Save and exit your editor. Then, source your `~/.bash_profile`.
jbd@bc4124e2017-01-05 23:28:35 -080021```bash
22$ source ~/.bash_profile
23```
24
jbd@fab88312017-01-06 17:17:16 -080025## Zsh
jbd@164ffea2017-01-05 23:31:00 -080026
27Edit `~/.zshrc` file to add the following line:
28
29```bash
30export GOPATH=$HOME/work
31```
32Save and exit your editor. Then, source your `~/.zshrc`.
33```bash
34$ source ~/.zshrc
35```
36
jbd@fab88312017-01-06 17:17:16 -080037# Windows
jbd@bc4124e2017-01-05 23:28:35 -080038
39Your workspace can be located wherever you like,
40but we'll use `C:\work` in this example.
jbd@c03fd472017-01-05 23:36:55 -080041Note that `GOPATH` must not be the same path as your Go installation.
jbd@bc4124e2017-01-05 23:28:35 -080042
43* Create folder at `C:\work`.
44* Right click on "Start" and click on "Control Panel". Select "System and Security", then click on "System".
45* From the menu on the left, select the "Advanced systems settings".
46* Click the "Environment Variables button at the bottom.
47* Click "New" from the "User variables" section.
48* Type `GOPATH` into the "Variable name" field.
49* Type `C:\work` into the "Variable value" field.
50* Click OK.
51
jbd@bc4124e2017-01-05 23:28:35 -080052