Skip to content

Commit

Permalink
fix: do not default goos/goarch/goarm if targets is provided (#1789)
Browse files Browse the repository at this point in the history
* fix: do not default goos/goarch/goarm if targets is provided

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* test: fixed

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
  • Loading branch information
caarlos0 committed Sep 6, 2020
1 parent 58cce33 commit 28230b6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
18 changes: 9 additions & 9 deletions internal/builders/golang/build.go
Expand Up @@ -41,19 +41,19 @@ func (*Builder) WithDefaults(build config.Build) config.Build {
if build.Main == "" {
build.Main = "."
}
if len(build.Goos) == 0 {
build.Goos = []string{"linux", "darwin"}
}
if len(build.Goarch) == 0 {
build.Goarch = []string{"amd64", "386"}
}
if len(build.Goarm) == 0 {
build.Goarm = []string{"6"}
}
if len(build.Ldflags) == 0 {
build.Ldflags = []string{"-s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser"}
}
if len(build.Targets) == 0 {
if len(build.Goos) == 0 {
build.Goos = []string{"linux", "darwin"}
}
if len(build.Goarch) == 0 {
build.Goarch = []string{"amd64", "386"}
}
if len(build.Goarm) == 0 {
build.Goarm = []string{"6"}
}
build.Targets = matrix(build)
}
if build.GoBinary == "" {
Expand Down
15 changes: 15 additions & 0 deletions internal/builders/golang/build_test.go
Expand Up @@ -71,6 +71,21 @@ func TestWithDefaults(t *testing.T) {
},
goBinary: "go",
},
"custom targets": {
build: config.Build{
ID: "foo3",
Binary: "foo",
Targets: []string{
"linux_386",
"darwin_amd64",
},
},
targets: []string{
"linux_386",
"darwin_amd64",
},
goBinary: "go",
},
} {
t.Run(name, func(tt *testing.T) {
var config = config.Project{
Expand Down

1 comment on commit 28230b6

@vercel
Copy link

@vercel vercel bot commented on 28230b6 Sep 6, 2020

Choose a reason for hiding this comment

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

Please sign in to comment.