In Go 1.11, a new tool has arrived. It's called
go mod. For those who don't know what is that, I'll tell you about it.
One of the purposes of this tool is to get rid of
$GOPATH, so you can
git clone a Golang repository anywhere and work on it without worrying about
$GOPATH at all. There are other purposes of course, such as simpler versioning and usage, but I think the RIP
$GOPATH is the most notable.
If the repository is a
mod, all the tools you use regularly (
go build, etc.) will handle it nicely without changing anything.
go mod init. Yep, that's all you have to do. If you're trying to
go mod-ify an existing project that uses
$GOPATH, you should export the
GO111MODULE=on variable (
go mod will tell you that as well).
There is a recommendation before creating a production tag: run
go mod tidy. This will update your
go.mod so every dependency (internal and which are used by dependencies)will be locked.
If you're interested, you can read the official wiki. It provides much more information about
go mod, I just gave you the basics that should set you up.
Goto definition and auto-completion works fine even without vendoring your dependencies in VS Code. I assume other editors that support Golang as good as Microsoft will handle
go mod nicely.
@rhymes wrote an article about
go mod as well and covered what he loves about it. I recommend to read it as well!
Top comments (1)
Thank you for the shout out! :-)
Can't wait for this feature to be finalized :)