custom build tags - seeing which files get selected

90 views
Skip to first unread message

White Hexagon

unread,
May 14, 2019, 8:40:49 AM5/14/19
to golang-nuts
My project is growing and I have started using custom build tags.  When I build the project I would really like to see a list of all the files that have been selected based on the tags I have requested.  Is that possible?  Thanks, Peter

Ian Lance Taylor

unread,
May 14, 2019, 9:49:19 AM5/14/19
to White Hexagon, golang-nuts
On Tue, May 14, 2019 at 5:41 AM 'White Hexagon' via golang-nuts
<golan...@googlegroups.com> wrote:
>
> My project is growing and I have started using custom build tags. When I build the project I would really like to see a list of all the files that have been selected based on the tags I have requested. Is that possible? Thanks, Peter

go list -f '{{.GoFiles}}' -tags MYTAGS PKG

Ian

White Hexagon

unread,
May 14, 2019, 11:17:38 AM5/14/19
to golang-nuts
Thanks Ian.

I should have mentioned that I am using go 1.12.1 with modules. 

So my 'main' package/module has a number of sub-folder packages as dependencies.  I found the -deps option, but that seems to include every dependency (also useful info) but is there a way to limit that to just my sources?

Thanks
Peter

Ian Cottrell

unread,
May 14, 2019, 3:59:23 PM5/14/19
to White Hexagon, golang-nuts
./... is a wildcard pattern that matches directories including and below the current one

go list -f '{{.GoFiles}}' -tags MYTAGS ./...

should do what you want.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/ad1f7316-807a-44b5-bf8b-b94a7dda51a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

White Hexagon

unread,
May 15, 2019, 12:58:05 AM5/15/19
to golang-nuts
Thanks, that's working just as I needed.  I have 4 build targets from a single pkg+ sub pkgs, so this lets me now see what's going on, and also keep an audit of what was built. 

It's a shame vscode can't flag the files, I'm having to use file names with the tags to find my way around, but at least it takes account of them once I found the setting:
{"go.buildTags": "tags"}

Thanks to both of you, Peter
Reply all
Reply to author
Forward
0 new messages