diff --git a/main.go b/main.go index b121ea5..5c8585e 100755 --- a/main.go +++ b/main.go @@ -31,6 +31,7 @@ import ( "encoding/json" _ "github.com/zhaojh329/rttys/statik" "github.com/rakyll/statik/fs" + "github.com/zhaojh329/rttys/version" ) type DeviceInfo struct { @@ -55,6 +56,9 @@ func main() { rand.Seed(time.Now().Unix()) + log.Println("BuildDate:", version.BuildDate) + log.Println("Gitref:", version.Gitref) + br := newBridge() go br.run() diff --git a/version/Makefile b/version/Makefile new file mode 100644 index 0000000..b4a4803 --- /dev/null +++ b/version/Makefile @@ -0,0 +1,20 @@ +BUILDDATE=`date +%F` +GITREF=`git describe --always --tags --long` + +# $(VERSION_GO) will be written to version.go +VERSION_GO="/* DO NOT EDIT THIS FILE. IT IS GENERATED BY 'make'*/\n\ +package version\n\ +var Gitref, BuildDate string\n" + +# $(GIT_GO) will be written to gitref.go +GITREF_GO="/* DO NOT EDIT THIS FILE. IT IS GENERATED BY make */ \n\n\ +package version\n\ +func init() { Gitref = \"$(GITREF)\"\nBuildDate= \"$(BUILDDATE)\"\n} " + +# +# setver updates version.go with VERSION +# +.PHONY:setver +setver: + @printf $(VERSION_GO) | gofmt > version.go + @printf $(GITREF_GO) | gofmt > git.go diff --git a/version/git.go b/version/git.go new file mode 100644 index 0000000..2791ba0 --- /dev/null +++ b/version/git.go @@ -0,0 +1,8 @@ +/* DO NOT EDIT THIS FILE. IT IS GENERATED BY make */ + +package version + +func init() { + Gitref = "0079594-dirty" + BuildDate = "2018-03-14" +} diff --git a/version/version.go b/version/version.go new file mode 100644 index 0000000..a4b32a9 --- /dev/null +++ b/version/version.go @@ -0,0 +1,4 @@ +/* DO NOT EDIT THIS FILE. IT IS GENERATED BY 'make'*/ +package version + +var Gitref, BuildDate string