-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
consts.go
66 lines (56 loc) · 1.39 KB
/
consts.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Package consts houses some constants needed across k6
package consts
import (
"fmt"
"runtime"
"runtime/debug"
"strings"
)
// Version contains the current semantic version of k6.
const Version = "0.54.0"
// FullVersion returns the maximally full version and build information for
// the currently running k6 executable.
func FullVersion() string {
goVersionArch := fmt.Sprintf("%s, %s/%s", runtime.Version(), runtime.GOOS, runtime.GOARCH)
buildInfo, ok := debug.ReadBuildInfo()
if !ok {
return fmt.Sprintf("%s (%s)", Version, goVersionArch)
}
var (
commit string
dirty bool
)
for _, s := range buildInfo.Settings {
switch s.Key {
case "vcs.revision":
commitLen := 10
if len(s.Value) < commitLen {
commitLen = len(s.Value)
}
commit = s.Value[:commitLen]
case "vcs.modified":
if s.Value == "true" {
dirty = true
}
default:
}
}
if commit == "" {
return fmt.Sprintf("%s (%s)", Version, goVersionArch)
}
if dirty {
commit += "-dirty"
}
return fmt.Sprintf("%s (commit/%s, %s)", Version, commit, goVersionArch)
}
// Banner returns the ASCII-art banner with the k6 logo
func Banner() string {
banner := strings.Join([]string{
` /\ Grafana /‾‾/ `,
` /\ / \ |\ __ / / `,
` / \/ \ | |/ / / ‾‾\ `,
` / \ | ( | (‾) |`,
` / __________ \ |_|\_\ \_____/ `,
}, "\n")
return banner
}