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

zimmski opened this Issue Sep 18, 2014 · 5 comments


None yet
7 participants
Copy link

zimmski commented Sep 18, 2014

The go command uses the function "importPaths" from 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.

This comment has been minimized.

Copy link

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.


This comment has been minimized.

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.

This comment has been minimized.

Copy link

dominikh commented Sep 18, 2014

Comment 3:

(shameless plug) At 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 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
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.

@zimmski zimmski added new labels Sep 18, 2014

@bradfitz bradfitz removed the new label Dec 18, 2014

@rsc rsc added this to the Unplanned milestone Apr 10, 2015

@rsc rsc removed release-none labels Apr 10, 2015


This comment has been minimized.

Copy link

ianlancetaylor commented Aug 1, 2018

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


This comment has been minimized.

Copy link

bcmills commented Jan 18, 2019

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

@bcmills bcmills closed this Jan 18, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.