Want to learn how to build better Go applications faster and easier? You can.
Check out my course on the Go Standard Library. You can check it out now for free.
A lot of folks ask “How do I set my GOPATH?” or.. “What is a GOPATH?” Hopefully we can answer that here today.
Since Go 1.11 you don’t need to use GOPATH. You can just create a go project instead.
But if you do want to set a GOPATH, here’s how you can do it.
In Linux, open up your ~/.bashrc
file.
Add these two lines:
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
After you save the file, type in
source ~/.bashrc
I like to install Go in my home directory, however you may change it to something different.
In the search bar, search for path:
In the next dialog select “Environment Variables”
Look for your path:
Look and see if GOPATH is included:
If it’s not, you can click “New” and add it:
Thanks for reading, and good luck on your Go adventures!