AdGuardHome/internal/version/version.go
Ainar Garipov e71019a1f3 Pull request: all: imp dev version handling
Merge in DNS/adguard-home from fix-version to master

Squashed commit of the following:

commit ecef63315fb49ae33b4c3f13c0e0be0668340e2b
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Jan 22 18:59:17 2021 +0300

    updater: imp tests

commit f5243918567430e467c44a48e45169db4560b58b
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Jan 22 18:48:10 2021 +0300

    all: imp dev version handling
2021-01-25 14:09:29 +03:00

61 lines
1.4 KiB
Go

// Package version contains AdGuard Home version information.
package version
import (
"fmt"
"runtime"
)
// These are set by the linker. Unfortunately we cannot set constants during
// linking, and Go doesn't have a concept of immutable variables, so to be
// thorough we have to only export them through getters.
//
// TODO(a.garipov): Find out if we can get GOARM and GOMIPS values the same way
// we can GOARCH and GOOS.
var (
channel string = ChannelDevelopment
goarm string
gomips string
version string
)
// Channel constants.
const (
ChannelDevelopment = "development"
ChannelEdge = "edge"
ChannelBeta = "beta"
ChannelRelease = "release"
)
// Channel returns the current AdGuard Home release channel.
func Channel() (v string) {
return channel
}
// Full returns the full current version of AdGuard Home.
func Full() (v string) {
msg := "AdGuard Home, version %s, channel %s, arch %s %s"
if goarm != "" {
msg = msg + " v" + goarm
} else if gomips != "" {
msg = msg + " " + gomips
}
return fmt.Sprintf(msg, version, channel, runtime.GOOS, runtime.GOARCH)
}
// GOARM returns the GOARM value used to build the current AdGuard Home release.
func GOARM() (v string) {
return goarm
}
// GOMIPS returns the GOMIPS value used to build the current AdGuard Home
// release.
func GOMIPS() (v string) {
return gomips
}
// Version returns the AdGuard Home build version.
func Version() (v string) {
return version
}