Best practice for GOPATH?

I started learning GO back before modules came around, so I used GOPATH. I drifted away for a while, but am coming back now. It’s unclear to me whether I should STILL define GOPATH, or whether it’s (somewhat?) obsolete now. Can someone help me, please?

Should I definitely have GOPATH defined? What bad things happen if I don’t?

What do most developers do these days? Do they have GOPATH, or NOT have it? What is the recommended method.

HI @tgphelps,

GOPATH is still used by the Go toolchain internally, for caching downloaded modules and compilation artifacts.

Developers do not have to care about GOPATH anymore. It has a default value (depending on OS), so you do not need to set it anymore.

Even if your code imports a package that has not moved to the module system yet, the Go toolchain takes care of that behind the scenes, by generating a pseudo version number for that package.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.