feat(*) add version info

This commit is contained in:
Guilherme Salazar
2020-01-08 14:58:23 -08:00
parent e9b9a58403
commit 63003ae67a
2 changed files with 24 additions and 5 deletions

View File

@@ -1,8 +1,10 @@
all=build
BIN_NAME=go-pluginserver
VERSION?=development
all: build
build:
go build -ldflags="-s -w" -o $(BIN_NAME) -v
go build -ldflags="-s -w -X main.version=$(VERSION)" -o $(BIN_NAME) -v
clean:
rm -rf $(BIN_NAME)

23
main.go
View File

@@ -4,17 +4,25 @@ package main
import (
"flag"
"runtime"
"github.com/ugorji/go/codec"
"log"
"net"
"net/rpc"
"os"
"reflect"
"fmt"
)
var kongPrefix = flag.String("kong-prefix", "/usr/local/kong", "Kong prefix path (specified by the -p argument commonly used in the kong cli)")
var dump = flag.String("dump-plugin-info", "", "Dump info about `plugin` as a MessagePack object")
var pluginsDir = flag.String("plugins-directory", "", "Set directory `path` where to search plugins")
var version = "development"
/* flags */
var (
kongPrefix = flag.String("kong-prefix", "/usr/local/kong", "Kong prefix path (specified by the -p argument commonly used in the kong cli)")
dump = flag.String("dump-plugin-info", "", "Dump info about `plugin` as a MessagePack object")
pluginsDir = flag.String("plugins-directory", "", "Set directory `path` where to search plugins")
showVersion = flag.Bool("version", false, "Print binary and runtime version")
)
var socket string
@@ -28,6 +36,10 @@ func init() {
}
}
func printVersion() {
fmt.Printf("Version: %s\nRuntime Version: %s\n", version, runtime.Version())
}
func dumpInfo() {
s := newServer()
@@ -88,6 +100,11 @@ func startServer() {
}
func main() {
if *showVersion == true {
printVersion()
os.Exit(0)
}
if *dump != "" {
dumpInfo()
os.Exit(0)