7 ms·
We've transitioned entirely to Go modules. It's been largely painless at the codebase level. Being able to ditch GOPATH is fantastic. It helps that "go mod init
by atombender 8y ago
We've transitioned entirely to Go modules. It's been largely painless at the codebase level. Being able to ditch GOPATH is fantastic. It helps that "go mod init" includes automatic migration from Dep. So far we haven't run into any serious bugs; compared to Dep (and Glide before it), "go mod" just works.
However, the toolchain is lagging [1], sometimes in quite serious ways. Pretty much every third-party tool that reads Go source code — linters, code generators and so on — uses an unofficial, largely undocumented package called golang.org/x/tools/go/loader to parse Go code into AST structures. This package has not been updated to understand Go modules, and so it fails, and it has been abandoned in favour of a new, also largely undocumented library, golang.org/x/tools/go/packages, that works completely differently. There's a tracking issue [1] that discusses the progress of converting these tools. There's no document that describes how to migrate.
It's annoying because we've come to rely on some, such as Mockery and go-sumtype, that still don't work with Go 1.11. In both cases the authors seem to have abandoned the projects, and updating the code isn't always so trivial.
[1] https://github.com/golang/go/issues/24661 https://github.com/golang/go/issues/24661
- xiaq 8y agoI don't think you really mean golang.org/x/tools/go/loader or golang.org/x/tools/go/packages are literally undocumented; simply pasting the URL gives you pretty detailed godoc for both packages. Rather, there is no official "how to load Go packages guide" pointing to those packages, and tool developers probably discovered those only by reading other source code. FWIW, the .../loader package is explicitly documented as experimental. The .../packages has a deadline of 1 Dec 2018 for breaking changes (both info found in their respective godoc)
- agnivade 8y agoThe tools team is still working on go/packages. It is bound to get better. Given that modules support is still officially experimental, there are bound to be rough edges. But by 1.12, I think we will have a solid modules story.