Browse Source

versioninfo added

Tobias Begalke 7 years ago
parent
commit
cfd7ce15ae
2 changed files with 13 additions and 1 deletions
  1. 5 1
      Makefile
  2. 8 0
      main.go

+ 5 - 1
Makefile

@@ -1,2 +1,6 @@
+VERSION=`git describe --tags`
+BUILD=`date +%FT%T%z`
+
+
 all:
-	go build -ldflags -s -tags netgo
+	go build -tags netgo -ldflags "-s -X main.Version=$(VERSION) -X main.BuildDate=$(BUILD)"

+ 8 - 0
main.go

@@ -26,10 +26,14 @@ var (
 	sleepFor     = flag.Duration("sleep", 0, "Sleep this long between sending data")
 	requestsFile = flag.String("requests", "", "CSV file containing requests (IP and URL)")
 	doProfile    = flag.Bool("profile", false, "Profile the program")
+	doVersion    = flag.Bool("version", false, "Show version information")
 
 	dataChan chan data.Request
 	natsEC   *nats.EncodedConn
 	count    uint64
+
+	Version   string
+	BuildDate string
 )
 
 func init() {
@@ -189,3 +193,7 @@ func replayMongoDB() {
 		}
 	}
 }
+
+func version() {
+	fmt.Printf("munchclient %s, built on %s\n", Version, BuildDate)
+}