-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: track tools/tooling updates to support modules #24661
Comments
Yes, this is an issue we're very aware of. Will leave this open to track it. |
@rsc - just to check this issue effectively encapsulates what we discussed in |
Changed the title so that this issue matches on use of the words "tool", "tools" or "tooling" Will keep a list of tools here too (please edit):
|
Change https://golang.org/cl/105855 mentions this issue: |
This CL is a work in progress for golang/go#24661. Following the pattern laid down by the vet command, we want to pass the build details of the transitive (test) deps of a list of packages onto vetters/linters etc that need to load imports of said packages for go/types (and similar) analysis. Fixes golang/go#24661 Change-Id: If1496dd6a3ed501ad6f124226a05f5d57284c57d
This CL is a work in progress for golang/go#24661. Following the pattern laid down by the vet command, we want to pass the build details of the transitive (test) deps of a list of packages onto vetters/linters etc that need to load imports of said packages for go/types (and similar) analysis. Fixes golang/go#24661 Change-Id: If1496dd6a3ed501ad6f124226a05f5d57284c57d
See https://go-review.googlesource.com/c/tools/+/116359 for a sketch of a start. |
Change https://golang.org/cl/125296 mentions this issue: |
…port The introduction of modules has broken (intentionally) the rule that the source code for a package x/y/z is in GOPATH/src/x/y/z (or GOROOT/src/x/y/z). This breaks the code in go/build.Import, which uses that rule to find the directory for a package. In the long term, the fix is to move programs that load packages off of go/build and onto golang.org/x/tools/go/packages, which we hope will eventually become go/packages. That code invokes the go command to learn what it needs to know about where packages are. In the short term, though, there are lots of programs that use go/build and will not be able to find code in module dependencies. To help those programs, go/build now runs the go command to ask where a package's source code can be found, if it sees that modules are in use. (If modules are not in use, it falls back to the usual lookup code and does not invoke the go command, so that existing uses are unaffected and not slowed down.) Helps #24661. Fixes #26504. Change-Id: I0dac68854cf5011005c3b2272810245d81b7cc5a Reviewed-on: https://go-review.googlesource.com/125296 Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
@alandonovan @ianthehat - is it worth creating a number of issues, specific to each tool that's being worked on? I keep directing people to this umbrella issue... but maybe there's merit in getting a bit more granularity on things? Equally, maybe not. So I'm definitely wouldn't push back if you said "let's keep things here" 👍 |
How about the case of
Assuming the following directory structure:
With
package main
import (
"log"
"example.com/test"
)
func main() {
log.Print("Hello, world!")
test.Start()
} With package test
import "fmt"
func Start() {
fmt.Println("Started properly")
} However, if the It's odd - Is this something that requires looking into the module cache for, or is this a different issue? |
It will be made to use x/tools/go/packages plus some extra stuff that is beyond the scope of that package. When it does, this case will work (does not involve the module cache, just the list of packages in the current module, which you can already get with |
Thank you for explaining @ianthehat! I've misunderstood how |
I have two questions:
|
Also: How to prevent that import completion will get really slow with larger projects? (see mdempsky/gocode#32) |
The plan is for it to move to the standard library at some point, yes, once it has stabilised (ref).
This is similar to the
Many of the problems describe in mdempsky/gocode#32 relate to speed problems brought about by the use of the But in case lag does become an issue for cc @dominikh (in case there's any overlap of interest here with your work) |
dvyukov/go-fuzz was listed above as not supporting modules, but updated list to indicate it does now support modules (dvyukov/go-fuzz#274). The current approach for go-fuzz works reasonably well for fuzzing modules, but it is not the "forever" solution for go-fuzz. In particular, the current approach will stop working if or when GOPATH mode goes away completely (because a portion of the implementation still relies on being able to disable module mode temporarily, though that is more-or-less transparent to the user). |
Change https://golang.org/cl/255053 mentions this issue: |
Maybe it's time to update this list? I'm pretty sure most of mentioned linters works just fine today with modules (at least within golangci-lint). Probably other things has changed too since Feb. |
Just went through and updated a bit. A lot of the tools in this list have been replaced by |
Also, remove obsolete -underscore option. Fixes golang/go#32031 Updates golang/go#24661 Change-Id: I47940a7ccfaf82a042eadc76f47304fc1dd8cbdd Reviewed-on: https://go-review.googlesource.com/c/tools/+/189818 Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
As of CL 189818, bundle has been updated to use the go/packages API to load packages. That API supports module mode and legacy GOPATH mode. Update the test to provide coverage for all modes. Updates golang/go#24661. Change-Id: Ied6196f7317b9b0289faf80dbfe9815e9b98b55d Reviewed-on: https://go-review.googlesource.com/c/tools/+/255053 Trust: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Filippo Valsorda <filippo@golang.org>
I am the author of gocyclo. It does not need an upgrade to support modules, it works on a file-by-file basis. |
maligned (github.com/mdempsky/maligned) is updated to support modules. (It's now implemented as an x/tools/go/analysis.Analyzer.) |
Not sure if this is useful for anyone, but I briefly looked at porting Basic findings (naive), which I am writing for myself should I ever wonder this again: Porting the tools does not look terribly difficult, but it appears that |
I ported eg already. But I see to my horror that I never hit submit. I’ll plan to do that when I’m next at a computer. https://go-review.googlesource.com/c/tools/+/258304 might be useful. |
At the risk of being too off-topic, if you found eg useful, you might want to take a look at https://github.com/rsc/rf. |
And just to briefly expand on @mvdan's comment, https://github.com/rsc/rf is also useful if you wanted a replacement for Here is a sample use, where you can see it doing
|
I appreciate the plug for rf. I am mainly looking for something that 1.
uses package packages under the hood (it does) and 2. at a maturity level
higher than experimental (not there yet) since I will want to point a large
user base of mixed skills at. :-). I’ll follow what’s happening there
closely; I promise.
|
Apropos to this conversation, rsc/rf originally used x/tools/go/packages, but for performance switched to a custom loader (which does not support GOPACKAGESDRIVER, at least currently): rsc/rf@8880f26 |
I wonder if there's value in keeping this issue open indefinitely. It's been three years, and practically every maintained Go tool now supports modules. For those that haven't done it yet, it probably makes sense to open an issue on their trackers and continue there. And if the tool isn't maintained anymore, it's always an option to fork and continue development. Perhaps we keep this issue open for a little longer (a year?), but I personally wouldn't go beyond that. The point of this issue was to coordinate work, keep track of progress, and potentially identify issues with supporting modules. I think we've succeeded at that :) |
It seems like we all agree this issue has served it's purpose, and should be closed soon. If you're the author or maintainer of a tool that still needs to add support for Go modules, please file an issue in your issue tracker about it, and link to it in a comment here for others to follow. Discussion and progress should continue there. I'll leave this issue open for another four weeks, to leave time for those comments, and any remaining input. Thanks! |
Apologies if this is not the right place to ask, but as far as I know, there still isn't a tool like |
@mvdan, thanks, but I've already tried I guess it's |
Four weeks elapsed, so closing. Thanks all for the work that happened here! |
Many Go tools that previously worked with GOPATH need to be upgraded in order to work with modules.
Note: Many of these tools have been deprecated with modules, and their features have been incorporated into
gopls
. This is indicated below.This is a tracking issue for the conversion of tools to work with modules.
gopls
, or cmd/fillstruct: broken without modules davidrjenni/reftools#31gopls
insteadgopls
gopls
or https://github.com/stamblerre/gocodegopls
orgh.neting.cc/rogpeppe/godef
gopls
gopls
gopls
golint- Deprecated - x/lint: freeze and deprecate #38968gometalinter- Deprecated - Archive gometalinter alecthomas/gometalinter#590gopls
gopls
gopls
vscode-go
)gopls
gopls
guru- replaced bygopls
gopls
The text was updated successfully, but these errors were encountered: