From 7cd0eb25584b4a8fdaed95b212a094521ae2abfd Mon Sep 17 00:00:00 2001 From: Alex Ungur Date: Thu, 7 Mar 2019 22:40:09 +0200 Subject: [PATCH] Got go list to respect the tags given --- go.go | 7 +++++-- main.go | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/go.go b/go.go index 37edb36..c57a5f0 100644 --- a/go.go +++ b/go.go @@ -122,9 +122,12 @@ func GoCrossCompile(opts *CompileOpts) error { // GoMainDirs returns the file paths to the packages that are "main" // packages, from the list of packages given. The list of packages can // include relative paths, the special "..." Go keyword, etc. -func GoMainDirs(packages []string, GoCmd string) ([]string, error) { - args := make([]string, 0, len(packages)+3) +func GoMainDirs(packages []string, GoCmd, tags string) ([]string, error) { + args := make([]string, 0, len(packages)+5) args = append(args, "list", "-f", "{{.Name}}|{{.ImportPath}}") + if tags != "" { + args = append(args, "-tags", tags) + } args = append(args, packages...) output, err := execGo(GoCmd, nil, "", args...) diff --git a/main.go b/main.go index d8098c9..3010de6 100644 --- a/main.go +++ b/main.go @@ -95,7 +95,7 @@ func realMain() int { } // Get the packages that are in the given paths - mainDirs, err := GoMainDirs(packages, flagGoCmd) + mainDirs, err := GoMainDirs(packages, flagGoCmd, tags) if err != nil { fmt.Fprintf(os.Stderr, "Error reading packages: %s", err) return 1