Simple and flexible way to fetch your app version.
Wether your app is a CLI or runs in background and generate logs, it's never been as easy to fetch your app version with this lib.
Supported resolvers:
- Environment variable
- AWS ECS Metadata File
- Fallback
- Composite
import "github.com/eexit/vresolver"
// Tries to fetch the version from the runtime ECS container
// and fallbacks to "bulk-version" otherwise
version := vresolver.Compose(
vresolver.Env,
vresolver.ECS,
vresolver.Fallback("bulk-version"),
)(vresolver.ECSMetadataFileEnvVar)
$ go get -u github.com/eexit/vresolver
$ go test -v -race ./...
You can build a custom resolver as long as it matches the following type:
type Resolver func(input string) string
For instance, let's create a Panic
resolver, that panics if no version is resolved:
// Panic panics when app has no version
func Panic(input string) string {
if input == "" {
panic("no app version was resolved")
}
return input
}
version := vresolver.Compose(vresolver.Env, Panic)("MY_APP_VERSION")