-
Notifications
You must be signed in to change notification settings - Fork 6
/
version.go
48 lines (41 loc) · 1.03 KB
/
version.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Package tl provides the core types and utility functions for transitland-lib.
package tl
import (
_ "embed"
"runtime/debug"
"strings"
)
// Read version from compiled in git details
var Version VersionInfo
func init() {
Version = getVersion()
}
type VersionInfo struct {
Tag string
Commit string
CommitTime string
}
func getVersion() VersionInfo {
ret := VersionInfo{}
info, _ := debug.ReadBuildInfo()
tagPrefix := "main.tag="
for _, kv := range info.Settings {
switch kv.Key {
case "vcs.revision":
ret.Commit = kv.Value
case "vcs.time":
ret.CommitTime = kv.Value
case "-ldflags":
for _, ss := range strings.Split(kv.Value, " ") {
if strings.HasPrefix(ss, tagPrefix) {
ret.Tag = strings.TrimPrefix(ss, tagPrefix)
}
}
}
}
return ret
}
// GTFSVERSION is the commit for the spec reference.md file.
var GTFSVERSION = "11a49075c1f50d0130b934833b7eeb3fe518961c"
// GTFSRTVERSION is the commit for the gtfs-realtime.proto file.
var GTFSRTVERSION = "6fcc3800b15954227af7335d571791738afb1a67"