@@ -26,15 +26,27 @@ var (
26
26
defaultVersionString = "0.3.7-alpha.preview"
27
27
versionString = ""
28
28
commit = ""
29
- buildDate = time. Time {}
29
+ buildDate = rfc3339Time {}
30
30
)
31
31
32
+ type rfc3339Time struct {
33
+ time.Time
34
+ }
35
+
36
+ func (r rfc3339Time ) format () string {
37
+ return r .Time .Format (time .RFC3339 )
38
+ }
39
+
40
+ func (r rfc3339Time ) MarshalJSON () ([]byte , error ) {
41
+ return []byte (`"` + r .format () + `"` ), nil
42
+ }
43
+
32
44
// Info FIXMEDOC
33
45
type Info struct {
34
- Application string `json:"Application"`
35
- VersionString string `json:"VersionString"`
36
- Commit string `json:"Commit"`
37
- BuildDate time. Time `json:"BuildDate"`
46
+ Application string `json:"Application"`
47
+ VersionString string `json:"VersionString"`
48
+ Commit string `json:"Commit"`
49
+ BuildDate rfc3339Time `json:"BuildDate"`
38
50
}
39
51
40
52
// NewInfo FIXMEDOC
@@ -48,13 +60,13 @@ func NewInfo(application string) *Info {
48
60
}
49
61
50
62
func (i * Info ) String () string {
51
- return fmt .Sprintf ("%s Version: %s Commit: %s BuildDate: %s" , i .Application , i .VersionString , i .Commit , i .BuildDate )
63
+ return fmt .Sprintf ("%s Version: %s Commit: %s BuildDate: %s" , i .Application , i .VersionString , i .Commit , i .BuildDate . format () )
52
64
}
53
65
54
66
//nolint:gochecknoinits
55
67
func init () {
56
68
if versionString == "" {
57
69
versionString = defaultVersionString
58
70
}
59
- buildDate = time .Now ().UTC ()
71
+ buildDate = rfc3339Time { time .Now ().UTC ()}
60
72
}
0 commit comments