package datekeys import ( "reflect" "runtime/debug" ) // SpecVersion is the version of the DateKeys Protocol Specification that this // module implements: spec/DateKeys_Protocol_Specification_v0.11.md, tagged // spec-v0.11 in its repository. It is neither the version of the module (see // Version) nor the versions inside the objects: the capsule format, 1 to 3, // and the schema versions (spec §22, §70). const SpecVersion = "0.15" // 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 }