https://github.com/ionos-cloud/go-appinfo
A package to provide version information settable during build time
https://github.com/ionos-cloud/go-appinfo
Last synced: 2 months ago
JSON representation
A package to provide version information settable during build time
- Host: GitHub
- URL: https://github.com/ionos-cloud/go-appinfo
- Owner: ionos-cloud
- License: apache-2.0
- Created: 2021-04-30T11:00:47.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-05-26T15:06:26.000Z (almost 4 years ago)
- Last Synced: 2025-01-30T23:27:23.499Z (3 months ago)
- Language: Go
- Size: 14.6 KB
- Stars: 0
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-appinfo
A package to provide application information settable during build time.
This package can be used to compile the application information into a binary. Useful, for example, when
building user agent strings (which is actually provided as function).This package does not make assumptions. It will provide the Compiler, Platform and GoVersion since these
values are unambiguously determinable by the Runtime. Other fields need to be set by the builder with ldflags.This example shows all settable attributes:
```shell
tag=$(git describe --tag)
commit=$(git rev-parse --short HEAD)
meta="buildhost:$HOSTNAME"
buildDate=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
treeState=$(test -n "`git status --porcelain`" && echo 'dirty' || echo 'clean')
go build -ldflags "\
-X github.com/ionos-cloud/go-appinfo.name=my-app \
-X github.com/ionos-cloud/go-appinfo.version=$tag \
-X github.com/ionos-cloud/go-appinfo.metadata=$meta \
-X github.com/ionos-cloud/go-appinfo.buildDate=$buildDate \
-X github.com/ionos-cloud/go-appinfo.gitCommit=$commit \
-X github.com/ionos-cloud/go-appinfo.gitTreeState=$treeState \
" ./...
```