I'm using gox to do parallel multiplatform builds, and it takes a parameter which is a text/template value describing the output location and name of the compiled binaries. I'm running into a problem because go-task wants to evaluate the template, and it just needs to be passed through.
buildall task:
buildall:
desc: Build 64bit versions for darwin, linux, and windows
cmds:
- gox -arch="amd64" -os="darwin linux windows" -output="./build/{{.Dir}}_{{.OS}}_{{.Arch}}" ./cmd/hello-world/
output:
$ task buildall
gox -arch="amd64" -os="darwin linux windows" -output="./build/<no value>_<no value>_<no value>" ./cmd/hello-world/
how can I escape the template in the task above so the template isn't evaluated by task?
The best option is probably to rely on golang template itself for escaping. Try
{{printf "/build/{{.Dir}}_{{.OS}}_{{.Arch}}"}} in your command.
Hi @conejo
For now the workaround @smyrman said should work. For the future, we may discuss choosing other delimiters:
build:
delims: ["${", "}"]
cmds:
- ...
I don't know gox well, but you can also have parallel builds with Task (all deps run in parallel):
build-all:
deps:
- task: build
vars: {OS: windows, arch: 386}
- task: build
vars: {OS: windows, arch: amd64}
- task: build
vars: {OS: linux, arch: 386}
- task: build
vars: {OS: linux, arch: amd64}
# others
build:
cmds:
- go build -o "dist/app_{{.OS}}_{{.ARCH}} ./cmd/app
env:
GOOS: "{{.OS}}"
GOARCH: "{{.GOARCH}}"
Thanks for the speedy assistance! The printf suggestion from @smyrman worked smoothly, and thanks @andreynering for giving me a different perspective and eliminating gox altogether.
Most helpful comment
Thanks for the speedy assistance! The printf suggestion from @smyrman worked smoothly, and thanks @andreynering for giving me a different perspective and eliminating gox altogether.