Skip to content
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: make path pattern matching functions available to go programmers #8768

Closed
zimmski opened this issue Sep 18, 2014 · 5 comments
Closed

Comments

@zimmski
Copy link
Contributor

zimmski commented Sep 18, 2014

The go command uses the function "importPaths" from
https://code.google.com/p/go/source/browse/src/cmd/go/main.go to resolve path patterns
like "net/...". Since this code is not exported other Go tools like
"golint" would have to reimplement or copy it. I propose that this should be
put into a public API so that third party Go projects can use the exact same behavior.

I am willing to do the coding part but I need some guidance on where I should move the
functions and how to properly name them.
@adg
Copy link
Contributor

adg commented Sep 18, 2014

Comment 1:

Another way to access the path expansion from outside the go tool is to invoke "go list".
I'll say from the outset that it's unlikely this will end up in the standard library,
and so the go tool itself wouldn't be able to use it even if it were available. If you
want to make it available now, put it in an external package available via "go get".

Labels changed: added release-none, repo-main.

@zimmski
Copy link
Contributor Author

zimmski commented Sep 18, 2014

Comment 2:

Using "go list" was already suggested to me by the golint maintainer
golang/lint#67 but I am sure that this will lead to open issues
concerning not finding the (correct) "go" executable. I also find it messy to rely on a
not normed output format of another tool.
Putting this in a public API would define a quasi standard for Go tools and it could be
also used by other official tools like gofmt and govet.

@dominikh
Copy link
Member

Comment 3:

(shameless plug) At https://github.com/kisielk/gotool we maintain copy&pasted exported
versions of functionality that the go command uses. Currently it only exports
ImportPaths, more would be added by request.
In my opinion, however, this is only a workaround. Having go tool related functionality
either in the standard library, or the go.tools repository (even though then the go tool
itself couldn't use it) would encourage writing 3rd party tools that behave correctly,
i.e. support the same functionality and input that the go tool supports. Right now,
everyone is writing their own code -- some tools do not support the "..." pattern, for
example.
As an aside, however, the format of "go list" can be normed however you want, it accepts
a template as one of its arguments, that specifies exactly what it outputs. And its
default output is also documented.

@ianlancetaylor
Copy link
Contributor

I think the current plan would be to use go/packages.

@bcmills
Copy link
Contributor

bcmills commented Jan 18, 2019

Agreed; go/packages should address exactly this use-case.

@bcmills bcmills closed this as completed Jan 18, 2019
@golang golang locked and limited conversation to collaborators Jan 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants