You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DateKeys/version.go

51 lines
1.3 KiB

package datekeys
import (
"reflect"
"runtime/debug"
)
// SpecVersion is the version of the DateKeys Protocol Specification that this
// module implements: spec/DateKeys_Protocol_Specification_v0.8.2.md, tagged
// spec-v0.8.2 in its repository. It is neither the version of the module
// (see Version) nor the framing and schema versions inside the objects,
// which are 1 (spec §70).
const SpecVersion = "0.8.2"
// modulePath is the path of this module: the import path of its root
// package, whatever the module is called.
var modulePath = reflect.TypeFor[Error]().PkgPath()
// Version returns the version of this module in the running program, as the
// go command recorded it: a release tag such as v0.1.0; a pseudo-version,
// which names the commit, for a program built in a checkout of the module;
// or "(devel)" when it is unknown, as in tests or under a replace directive
// that points to a directory.
func Version() string {
info, ok := debug.ReadBuildInfo()
if !ok {
return "(devel)"
}
return versionIn(info)
}
func versionIn(info *debug.BuildInfo) string {
m := &info.Main
if m.Path != modulePath {
m = nil
for _, d := range info.Deps {
if d.Path == modulePath {
m = d
break
}
}
}
if m != nil && m.Replace != nil {
m = m.Replace
}
if m == nil || m.Version == "" {
return "(devel)"
}
return m.Version
}

Powered by TurnKey Linux.