-
Notifications
You must be signed in to change notification settings - Fork 69
/
runtimeversions.go
50 lines (44 loc) · 1.43 KB
/
runtimeversions.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
package device
import (
"runtime"
)
// Cached runtime versions that can be updated globally by framework
// integrations through AddVersion.
var versions *RuntimeVersions
// RuntimeVersions define the various versions of Go and any framework that may
// be in use.
// As a user of the notifier you're unlikely to need to modify this struct.
// As such, the authors reserve the right to introduce breaking changes to the
// properties in this struct. In particular the framework versions are liable
// to change in new versions of the notifier in minor/patch versions.
type RuntimeVersions struct {
Go string `json:"go"`
Gin string `json:"gin,omitempty"`
Martini string `json:"martini,omitempty"`
Negroni string `json:"negroni,omitempty"`
Revel string `json:"revel,omitempty"`
}
// GetRuntimeVersions retrieves the recorded runtime versions in a goroutine-safe manner.
func GetRuntimeVersions() *RuntimeVersions {
if versions == nil {
versions = &RuntimeVersions{Go: runtime.Version()}
}
return versions
}
// AddVersion permits a framework to register its version, assuming it's one of
// the officially supported frameworks.
func AddVersion(framework, version string) {
if versions == nil {
versions = &RuntimeVersions{Go: runtime.Version()}
}
switch framework {
case "Martini":
versions.Martini = version
case "Gin":
versions.Gin = version
case "Negroni":
versions.Negroni = version
case "Revel":
versions.Revel = version
}
}