-
Notifications
You must be signed in to change notification settings - Fork 49
/
constants.go
46 lines (40 loc) · 1.18 KB
/
constants.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
package common
import "fmt"
const (
KiloByte = 1000 // kB
KibiByte = 1024 // KiB
MegaByte = 1000 * 1000 // MB
MebiByte = 1024 * 1024 // MiB
GigaByte = 1000 * 1000 * 1000 // GB
GibiByte = 1024 * 1024 * 1024 // GiB
TeraByte = 1000 * 1000 * 1000 * 1000 // TB
TebiByte = 1024 * 1024 * 1024 * 1024 // TiB
// shorthands
KiB = KibiByte
MB = MegaByte
MiB = MebiByte
GB = GigaByte
GiB = GibiByte
TiB = TebiByte
)
// These constants are set during buildtime using additional
// compiler flags. Not all of them are necessarily defined
// because RPMs can be build from a tarball and spec file without
// being in a git repository. On the other hand when building
// composer inside of a container, there is no RPM layer so in
// that case the RPM version doesn't exist at all.
var (
// Git revision from which this code was built
GitRev = "undefined"
// RPM Version
RpmVersion = "undefined"
)
func BuildVersion() string {
if GitRev != "undefined" {
return fmt.Sprintf("git-rev:%s", GitRev)
} else if RpmVersion != "undefined" {
return fmt.Sprintf("NEVRA:%s", RpmVersion)
} else {
return "devel"
}
}