Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cmd/multibuild/multibuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ func targetList() ([]target, error) {

// Returns the binary name/path that `go build` would produce.
func determineTargetName(args []string) (string, error) {
for i := 0; i < len(args); i++ {
for i := range args {
arg := args[i]

if arg == "-o" && i+1 < len(args) {
return args[i+1], nil
}

if strings.HasPrefix(arg, "-o=") {
return strings.TrimPrefix(arg, "-o="), nil
if after, ok := strings.CutPrefix(arg, "-o="); ok {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, nice! Didn't actually know about that one.

return after, nil
}
}

Expand Down Expand Up @@ -99,7 +99,7 @@ func determineTargetName(args []string) (string, error) {
}

func displayUsageAndExit(self string) {
fmt.Fprintln(os.Stderr, fmt.Sprintf("usage: %s [-o output] [build flags] [packages]", self))
fmt.Fprintf(os.Stderr, "usage: %s [-o output] [build flags] [packages]\n", self)
fmt.Fprintln(os.Stderr, "multibuild is a thin wrapper around 'go build'.")
fmt.Fprintln(os.Stderr, "For documentation on multibuild's configuration, see https://github.com/rburchell/multibuild")
fmt.Fprintln(os.Stderr, "Otherwise, run 'go help build' for command line flags.")
Expand Down
9 changes: 2 additions & 7 deletions cmd/multibuild/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io"
"log"
"os"
"slices"
"strings"
)

Expand Down Expand Up @@ -62,13 +63,7 @@ func (this options) buildTargetList(targets []target) ([]target, error) {

// Check includes still present
for _, inc := range this.Include {
found := false
for _, t := range targets {
if inc.matches(t) {
found = true
break
}
}
found := slices.ContainsFunc(targets, inc.matches)
if !found {
return nil, fmt.Errorf("multibuild: required target %q was not found, or was excluded", inc)
}
Expand Down
9 changes: 2 additions & 7 deletions cmd/multibuild/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package main

import (
"os"
"slices"
"strings"
"testing"
)
Expand Down Expand Up @@ -264,13 +265,7 @@ func TestScanBuildDir_ExcludeDefaultCGO(t *testing.T) {
// Unset CGO_ENABLED
os.Setenv("CGO_ENABLED", "0")
opts, _ := scanBuildDir([]string{file})
found := false
for _, x := range opts.Exclude {
if x == "android/*" {
found = true
break
}
}
found := slices.Contains(opts.Exclude, "android/*")
if !found {
t.Errorf("expected android/* to be excluded when CGO_ENABLED=0, got excludes %v", opts.Exclude)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/multibuild/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"os"
)

func fatal(format string, args ...interface{}) {
func fatal(format string, args ...any) {
format += "\n"
fmt.Fprintf(os.Stderr, format, args...)
os.Exit(1)
Expand Down
Loading