How to Set Your Gopath

Hey! If you love Go and building Go apps as much as I do, let's connect on Twitter or LinkedIn. I talk about this stuff all the time!

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

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 Windows

In the search bar, search for path:

How to set GOPATH

In the next dialog select “Environment Variables”

How to set GOPATH

Look for your path:

How to set GOPATH

Look and see if GOPATH is included:

How to set GOPATH

If it’s not, you can click “New” and add it:

How to set GOPATH

Thanks for reading, and good luck on your Go adventures!



Stay up to date on the latest in Coding for AI and Data Science

Intuit Mailchimp