()
| 31 | const unknown = "<unknown>" |
| 32 | |
| 33 | func GetVersion() string { |
| 34 | if Version != "" { |
| 35 | return Version |
| 36 | } |
| 37 | /* |
| 38 | * go install example.com/cmd/foo@vX.Y.Z: bi.Main.Version="vX.Y.Z", vcs.revision is unset |
| 39 | * go install example.com/cmd/foo@latest: bi.Main.Version="vX.Y.Z", vcs.revision is unset |
| 40 | * go install example.com/cmd/foo@master: bi.Main.Version="vX.Y.Z-N.yyyyMMddhhmmss-gggggggggggg", vcs.revision is unset |
| 41 | * go install ./cmd/foo: bi.Main.Version="(devel)", vcs.revision="gggggggggggggggggggggggggggggggggggggggg" |
| 42 | * vcs.time="yyyy-MM-ddThh:mm:ssZ", vcs.modified=("false"|"true") |
| 43 | */ |
| 44 | if bi, ok := debug.ReadBuildInfo(); ok { |
| 45 | if bi.Main.Version != "" && bi.Main.Version != "(devel)" { |
| 46 | return bi.Main.Version |
| 47 | } |
| 48 | } |
| 49 | return unknown |
| 50 | } |
| 51 | |
| 52 | func GetRevision() string { |
| 53 | if Revision != "" { |
no outgoing calls
no test coverage detected
searching dependent graphs…