From 8e0d64fe06b802560bdfdc8432e8bfded5cf7bb9 Mon Sep 17 00:00:00 2001 From: Matt Jaffee Date: Thu, 9 Mar 2017 10:55:53 -0600 Subject: [PATCH 1/2] give appropriate path in ldflags for BuildTime and Version --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a78239a88..c4d21dc28 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ VERSION := $(shell git describe --tags) IDENTIFIER := $(VERSION)-$(GOOS)-$(GOARCH) CLONE_URL=github.com/pilosa/pilosa BUILD_TIME=`date -u +%FT%T%z` -LDFLAGS=-ldflags "-X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME)" +LDFLAGS=-ldflags "-X github.com/pilosa/pilosa/cmd.Version=$(VERSION) -X github.com/pilosa/pilosa/cmd.BuildTime=$(BUILD_TIME)" default: test pilosa From 72de534c8caff3252115deda6d4766ec93706051 Mon Sep 17 00:00:00 2001 From: Matt Jaffee Date: Thu, 9 Mar 2017 11:39:11 -0600 Subject: [PATCH 2/2] remove duplicate Version/BuildTime from pilosa/server use only the pilosa/cmd Version and BuildTime which are populated by the ldflags in the Makefile --- cmd/server.go | 4 ++-- server/server.go | 13 ------------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/cmd/server.go b/cmd/server.go index efff0ac7d..9b5821aa2 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -25,8 +25,8 @@ It will load existing data from the configured directory, and start listening client connections on the configured port.`, Run: func(cmd *cobra.Command, args []string) { - serve.Server.Handler.Version = server.Version - fmt.Fprintf(serve.Stderr, "Pilosa %s, build time %s\n", server.Version, server.BuildTime) + serve.Server.Handler.Version = Version + fmt.Fprintf(serve.Stderr, "Pilosa %s, build time %s\n", Version, BuildTime) // Parse command line arguments. if err := serve.SetupConfig(args); err != nil { diff --git a/server/server.go b/server/server.go index 845340485..85b3dbb77 100644 --- a/server/server.go +++ b/server/server.go @@ -14,20 +14,7 @@ import ( "github.com/pilosa/pilosa" ) -// Version and BuildTime hold the version/build time information passed in at compile time. -var ( - Version string - BuildTime string -) - func init() { - if Version == "" { - Version = "v0.0.0" - } - if BuildTime == "" { - BuildTime = "not recorded" - } - rand.Seed(time.Now().UTC().UnixNano()) }