Skip to content

Commit

Permalink
fix(golang): additional args
Browse files Browse the repository at this point in the history
  • Loading branch information
franklinkim committed Feb 26, 2025
1 parent 6fd4f69 commit 8f28919
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions golang/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,19 @@ func (c *Command) build(ctx context.Context, r *readline.Readline) error {
}
slices.Sort(paths)

args := c.getBuildTags()
if r.AdditionalArgs().Len() > 1 {
args = r.AdditionalArgs().From(1)
}

ctx, wg := c.wg(ctx, r)
c.l.Info("Running go build ...")
for _, value := range paths {
wg.Go(func() error {
c.l.Info("└ " + value)
return shell.New(ctx, c.l, "go", "build", "-v").
Args(c.getBuildTags()...).
Args(r.Flags()...).
Args(args...).
Args(r.AdditionalArgs().From(1)...).
Args("./..."). // TODO select test
Dir(value).
Run()
Expand All @@ -238,14 +243,18 @@ func (c *Command) test(ctx context.Context, r *readline.Readline) error {
envs = append(envs, "GO_TEST_TAGS="+value)
}

args := c.getBuildTags()
if r.AdditionalArgs().Len() > 1 {
args = r.AdditionalArgs().From(1)
}

ctx, wg := c.wg(ctx, r)
c.l.Info("Running go test ...")
for _, value := range paths {
wg.Go(func() error {
c.l.Info("└ " + value)
return shell.New(ctx, c.l, "go", "test", "-v").
Args(c.getBuildTags()...).
Args(r.Flags()...).
Args(args...).
Args("./..."). // TODO select test
Env(envs...).
Dir(value).
Expand All @@ -264,6 +273,11 @@ func (c *Command) modTidy(ctx context.Context, r *readline.Readline) error {
}
slices.Sort(paths)

var args []string
if r.AdditionalArgs().Len() > 1 {
args = r.AdditionalArgs().From(1)
}

ctx, wg := c.wg(ctx, r)
c.l.Info("Running go mod tidy...")
for _, value := range paths {
Expand All @@ -272,7 +286,7 @@ func (c *Command) modTidy(ctx context.Context, r *readline.Readline) error {
return shell.New(ctx, c.l,
"go", "mod", "tidy",
).
Args(r.AdditionalArgs()...).
Args(args...).
Dir(value).
Run()
})
Expand All @@ -289,6 +303,11 @@ func (c *Command) modDownload(ctx context.Context, r *readline.Readline) error {
}
slices.Sort(paths)

var args []string
if r.AdditionalArgs().Len() > 1 {
args = r.AdditionalArgs().From(1)
}

ctx, wg := c.wg(ctx, r)
c.l.Info("Running go mod download...")
for _, value := range paths {
Expand All @@ -297,7 +316,7 @@ func (c *Command) modDownload(ctx context.Context, r *readline.Readline) error {
return shell.New(ctx, c.l,
"go", "mod", "download",
).
Args(r.AdditionalArgs()...).
Args(args...).
Dir(value).
Run()
})
Expand All @@ -324,7 +343,6 @@ func (c *Command) modOutdated(ctx context.Context, r *readline.Readline) error {
"-u", "-m", "-json", "all",
"|", "go-mod-outdated", "-update", "-direct",
).
Args(r.AdditionalArgs()...).
Dir(value).
Run()
})
Expand Down

0 comments on commit 8f28919

Please sign in to comment.