go-gitver/examples/basic
AJ ONeal 9f05e2304c rename outfile xversion.go to lower init() priority, add outfile option 2019-06-21 00:01:02 -06:00
..
tools fix docs, add more docs, allow different package name 2019-06-20 23:27:41 -06:00
README.md rename outfile xversion.go to lower init() priority, add outfile option 2019-06-21 00:01:02 -06:00
go.mod rename outfile xversion.go to lower init() priority, add outfile option 2019-06-21 00:01:02 -06:00
main.go v1.0.0: get version from git, or fail gracefully 2019-06-20 22:55:24 -06:00

README.md

Example

Prints the version or a nice message

Build

Typically the developer would perform these steps and then commit the results (go.mod, go.sum, vendor).

However, since this is an example within the project directory, that seemed a little redundant.

go mod tidy
go mod vendor

These are the instructions that someone cloning the repo might use.

go generate -mod=vendor ./...
go build -mod=vendor -o hello *.go
./hello
./hello --version

Note: If the source is distributed in a non-git tarball then version-generated.go will not be output, and whatever version info is in package main will remain as-is.

If you would prefer the build process to fail (i.e. in a CI/CD pipeline), you can set the environment variable GITVER_FAIL=true.