2019-06-21 04:55:24 +00:00
|
|
|
# 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.
|
|
|
|
|
|
|
|
```bash
|
|
|
|
go mod tidy
|
|
|
|
go mod vendor
|
|
|
|
```
|
|
|
|
|
|
|
|
These are the instructions that someone cloning the repo might use.
|
|
|
|
|
|
|
|
```bash
|
|
|
|
go generate -mod=vendor ./...
|
|
|
|
go build -mod=vendor -o hello *.go
|
2019-06-21 05:27:41 +00:00
|
|
|
./hello
|
|
|
|
./hello --version
|
2019-06-21 04:55:24 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Note: If the source is distributed in a non-git tarball then
|
2019-06-21 06:01:02 +00:00
|
|
|
`version-generated.go` will not be output, and whatever
|
2019-06-21 04:55:24 +00:00
|
|
|
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`.
|