T
Task6mo ago
José

commands composition?

Hi! I need to build my go program but i have some options. First: - GOOS=linux GOARCH=arm64 - Native. Second: - Use X or Y implementation of a specific thing. Third: - If Y was chosen, three alternatives for a ldflag (let's call them: 'a', 'b', setted by the user as a var on the task call) so, y commands could look like:
1. GOOS=linux GOARCH=arm64 go build -ldflags "-X 'use X'"
2. GOOS=linux GOARCH=arm64 go build -ldflags "-X 'use Y' -X 'value is a'"
3. GOOS=linux GOARCH=arm64 go build -ldflags "-X 'use Y' -X 'value is b'"
4. GOOS=linux GOARCH=arm64 go build -ldflags "-X 'use Y' -X 'value is what the user gave you'"
5. go build -ldflags "-X 'use X'"
6. go build -ldflags "-X 'use Y' -X 'value is a'"
7. go build -ldflags "-X 'use Y' -X 'value is b'"
8. go build -ldflags "-X 'use Y' -X 'value is what the user gave you'"
1. GOOS=linux GOARCH=arm64 go build -ldflags "-X 'use X'"
2. GOOS=linux GOARCH=arm64 go build -ldflags "-X 'use Y' -X 'value is a'"
3. GOOS=linux GOARCH=arm64 go build -ldflags "-X 'use Y' -X 'value is b'"
4. GOOS=linux GOARCH=arm64 go build -ldflags "-X 'use Y' -X 'value is what the user gave you'"
5. go build -ldflags "-X 'use X'"
6. go build -ldflags "-X 'use Y' -X 'value is a'"
7. go build -ldflags "-X 'use Y' -X 'value is b'"
8. go build -ldflags "-X 'use Y' -X 'value is what the user gave you'"
I'd like to call my tasks something like:
task linux x build
task linux y a build
task linux y b build
VALUE=c task linux y build
task x build
task y a build
task y b build
VALUE=c task y build
task linux x build
task linux y a build
task linux y b build
VALUE=c task linux y build
task x build
task y a build
task y b build
VALUE=c task y build
is there a way to do that?
2 Replies
andreynering
andreynering6mo ago
Hi @José, Isn't this something that will work for you?
version: '3'

tasks:
internal_build:
cmds:
- env GOOS={{.GOOS}} GOARCH={{.GOARCH}} go build -ldflags "{{.LDFLAGS}}"

build-linux-amd64:
cmds:
- tasks: internal-build
vars:
GOOS: linux
GOARCH: amd64
LDFLAGS: foobarbaz

# tasks for other paltforms here...
version: '3'

tasks:
internal_build:
cmds:
- env GOOS={{.GOOS}} GOARCH={{.GOARCH}} go build -ldflags "{{.LDFLAGS}}"

build-linux-amd64:
cmds:
- tasks: internal-build
vars:
GOOS: linux
GOARCH: amd64
LDFLAGS: foobarbaz

# tasks for other paltforms here...
José
JoséOP6mo ago
i'll give it a try and came back
Want results from more Discord servers?
Add your server