Take this backend build function:
// Returns the built binary for the Go source code
func (m *Backend) Build(
// source code you want to built
source *Directory,
// os you want to build for
// +optional
// +default="linux"
os string,
// architecture you want to build for
// +optional
arch string) *File {
if arch == "" {
arch = runtime.GOARCH
}
return dag.Container().From("golang:latest").
WithMountedDirectory("/src", source).
WithWorkdir("/src").
WithEnvVariable("GOOS", os).
WithEnvVariable("GOARCH", arch).
WithExec([]string{"go", "build", "-o", "greetings"}).
File("/src/greetings")
}
If I'm calling this function from a parent module how do I pass in the os and arch flags? I understand how to do it with the CLI but not in code. I want to pass the os here:
backendBuild := dag.Backend().Build(source)
Thanks!