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

Open
zimmski opened this Issue Sep 18, 2014 · 4 comments

Comments

Projects
None yet
6 participants
@zimmski
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

This comment has been minimized.

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

This comment has been minimized.

Contributor

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

This comment has been minimized.

Member

dominikh commented Sep 18, 2014

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.

@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

@ianlancetaylor

This comment has been minimized.

Contributor

ianlancetaylor commented Aug 1, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment