File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -2,9 +2,11 @@ package main
22
33import (
44 "errors"
5+ "fmt"
56 "log"
67 "os"
78 "os/signal"
9+ "runtime/debug"
810 "syscall"
911)
1012
@@ -14,6 +16,7 @@ const (
1416 LOCAL RunType = iota
1517 WORKER
1618 SERVER
19+ UTIL_VERSION
1720)
1821
1922func ParseType (args []string ) (RunType , []string ) {
@@ -30,6 +33,9 @@ func ParseType(args []string) (RunType, []string) {
3033 case "-local" :
3134 t = LOCAL
3235 continue
36+ case "-version" :
37+ t = UTIL_VERSION
38+ continue
3339 }
3440
3541 resArgs = append (resArgs , arg )
@@ -59,6 +65,26 @@ func ParseConfigName(args []string) (string, []string) {
5965
6066func main () {
6167 t , args := ParseType (os .Args [1 :])
68+
69+ if t == UTIL_VERSION {
70+ info , ok := debug .ReadBuildInfo ()
71+ if ! ok {
72+ fmt .Println ("unknown" )
73+ return
74+ }
75+ for _ , kv := range info .Settings {
76+ if kv .Value == "" {
77+ continue
78+ }
79+ switch kv .Key {
80+ case "vcs.revision" :
81+ fmt .Println (kv .Value )
82+ return
83+ }
84+ }
85+ return
86+ }
87+
6288 configFile , args := ParseConfigName (args )
6389
6490 var config ConfigRoot
You can’t perform that action at this time.
0 commit comments