Skip to content

Commit

Permalink
Allow to specify build tags
Browse files Browse the repository at this point in the history
  • Loading branch information
foxcpp committed Mar 23, 2019
1 parent 730fcbb commit 6ba5957
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@ var (

var (
jsonOutput = kingpin.Flag("json", "Output json").Short('j').Bool()
buildTags = kingpin.Flag("tags", "Build tags").String()
)

func main() {
kingpin.Version(fmt.Sprintf("%s (%s)", version, commit))
kingpin.Parse()
weight := pkg.NewGoWeight()
if *buildTags != "" {
weight.BuildArgs = "-tags " + *buildTags
}

work := weight.BuildCurrent()
modules := weight.Process(work)

Expand Down
3 changes: 2 additions & 1 deletion pkg/goweight.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ type ModuleEntry struct {
SizeHuman string `json:"size_human"`
}
type GoWeight struct {
BuildArgs string
}

func NewGoWeight() *GoWeight {
return &GoWeight{}
}

func (g *GoWeight) BuildCurrent() string {
return strings.Split(strings.TrimSpace(run("go build -work -a 2>&1")), "=")[1]
return strings.Split(strings.TrimSpace(run("go build "+g.BuildArgs+" -work -a 2>&1")), "=")[1]
}
func (g *GoWeight) Process(work string) []*ModuleEntry {

Expand Down

0 comments on commit 6ba5957

Please sign in to comment.