Skip to content
This repository was archived by the owner on May 8, 2023. It is now read-only.
This repository was archived by the owner on May 8, 2023. It is now read-only.

Please add a pre_build_example.go to inject a custom version #118

@robertranjan

Description

@robertranjan

I found this tool from awesome-go and liked as it has the pre_build, post_build hooks. I couldn't figure out how to inject some build vars or update existing ones. It'd appreciated if you add a pre_build_example.go to inject some build parameters.

Looked at the code but not sure how it works...

By the time you call the preHook all set(everything read into memory) for the build. Not sure, how to inject build params/variables.

-- snip from ./internal/builder/builder.go ---

if err := builder.RunProjectHook(project, common.ScriptPreBuild, buildArgs); err != nil {
	return err
}

if err := builder.RunToStdout(
	buildCmd,
	project.Path,
	map[string]string{
		"GO111MODULE": "on",
		"GOOS":        builder.GOOS,
		"GOARCH":      builder.GOARCH,
	},
); err != nil {
	return err
}

return builder.RunProjectHook(project, common.ScriptPostBuild, buildArgs)

pre_build_example.go for below would be nice:

  • how to add an additional -X flag to --ldflag?
  • how to update version to add some .xyz suffix?

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions