-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmeta.go
64 lines (56 loc) · 1.19 KB
/
meta.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
// Meta provides metadata about the Run project, like contributor and
// license information.
//
// The project itself can be imported from package,
// github.com/amonks/run/pkg/run
package meta
import (
_ "embed"
"runtime/debug"
"strings"
)
var Version string = "devel"
var (
Revision string = "unknown"
ReleaseDate string = "unknown"
DirtyBuild bool
)
func init() {
info, ok := debug.ReadBuildInfo()
if !ok {
return
}
for _, kv := range info.Settings {
switch kv.Key {
case "vcs.revision":
Revision = kv.Value
case "vcs.time":
ReleaseDate = kv.Value
case "vcs.modified":
if kv.Value == "true" {
DirtyBuild = true
} else if kv.Value == "false" {
DirtyBuild = false
} else {
panic("unexpected vcs.modified value")
}
}
}
}
//go:generate go run github.com/amonks/run/cmd/licenses CREDITS.txt
//go:embed CREDITS.txt
var Credits string
//go:embed LICENSE.md
var License string
//go:embed CONTRIBUTORS.md
var contributors string
var Contributors string
func init() {
var b strings.Builder
for _, line := range strings.Split(contributors, "\n") {
if strings.HasPrefix(line, "- ") {
b.WriteString(line + "\n")
}
}
Contributors = b.String()
}