Merge pull request #387 from jaffee/384-time-version-bug

give appropriate path in ldflags for BuildTime and Version
This commit is contained in:
Matthew Jaffee 2017-03-09 12:01:08 -06:00 committed by GitHub
commit e8ab4cfc2d
3 changed files with 3 additions and 16 deletions

View file

@ -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

View file

@ -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 {

View file

@ -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())
}