forked from wish/eventmaster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.go
39 lines (33 loc) · 863 Bytes
/
version.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
package eventmaster
import (
"encoding/json"
"fmt"
"net/http"
"os"
"github.com/julienschmidt/httprouter"
log "github.com/sirupsen/logrus"
)
// Version maps to tagged releases of the software.
var Version = "unset"
// Git stores the commit used during build.
var Git = "unset"
func (h *Server) version(w http.ResponseWriter, req *http.Request, p httprouter.Params) {
w.Header().Set("Content-Type", "application/json")
r := struct {
Version string `json:"version"`
Git string `json:"git"`
}{
Version: Version,
Git: Git,
}
if err := json.NewEncoder(w).Encode(&r); err != nil {
log.Errorf("json encode: %v", err)
}
}
// PrintVersions writes version information for the running binary to stdout.
func PrintVersions() {
cmd := os.Args[0]
fmt.Printf("%v\n", cmd)
fmt.Printf("version: %v\n", Version)
fmt.Printf("git@%v\n", Git)
}