Skip to content

Repository files navigation

V(ersion) Resolver Build Statuscodecov

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:

Example

import"github.com/eexit/vresolver"// Tries to fetch the version from the runtime ECS container// and fallbacks to "bulk-version" otherwiseversion:=vresolver.Compose(
vresolver.Env,
vresolver.ECS,
vresolver.Fallback("bulk-version"),
)(vresolver.ECSMetadataFileEnvVar)

Installation

$ go get -u github.com/eexit/vresolver

Test

$ go test -v -race ./...

Custom resolver

You can build a custom resolver as long as it matches the following type:

typeResolverfunc(inputstring) string

For instance, let's create a Panic resolver, that panics if no version is resolved:

// Panic panics when app has no versionfuncPanic(inputstring) string {
ifinput=="" {
panic("no app version was resolved")
}
returninput
}
version:=vresolver.Compose(vresolver.Env, Panic)("MY_APP_VERSION")

About

Simple and flexible way to fetch your app version

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages