Skip to content
This repository has been archived by the owner on Jan 26, 2019. It is now read-only.

Add support for build tags #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ func main() {
tmpfile += ".exe"
}

passthrough("go", "build", "-i", "-o", tmpfile, pkg)
buildOptions := []string{"build", "-i", "-o", tmpfile}
if tags := os.Getenv("BUILD_TAGS"); tags != "" {
buildOptions = append(buildOptions, "-tags", tags)
}
buildOptions = append(buildOptions, pkg)

passthrough("go", buildOptions...)
passthrough(tmpfile, os.Args[2:]...)
}

Expand Down
7 changes: 7 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,10 @@ then go generate:
```bash
go generate ./...
```

You can enable build tags by setting the `BUILD_TAGS` environment variable.
The following is a `go:generate` example with the `golang-migrate/migrate` library:

```go
//go:generate bash -c "BUILD_TAGS=postgres gorunpkg github.com/golang-migrate/migrate/cli --help"
```