GOPATH Environment Variable

Raymond Tang Raymond Tang 0 449 0.35 index 12/25/2021

GOPATH environment variable (%GOPATH%, $GOPATH) will be created after you install Go on your computer.

What is it for?

This environment variable is used to find Go workspaces which contains binaries, packages, etc. For example, once

The default location is %USERPROFILE%/go on Windows or $HOME/go on Linux. Basically it locates in a subfolder named gounder your user home folder.

Change it to other directory

Windows

To change it on Windows machine, go to Edit the system environment variable ->  Environment Variables:

2021122514903-image.png

Click GOPATHvariable and then edit the value:

2021122515049-image.png

Click OKbutton to save the changes.

Linux

To change it on UNIX-alike systems, edit .bashrc or .profile file.

2021122520131-image.png

go

Join the Discussion

View or add your thoughts below

Comments