1
0
mirror of https://github.com/alice-lg/alice-lg.git synced 2024-05-11 05:55:03 +00:00

set version at compiletime

This commit is contained in:
Matthias Hannig
2017-05-19 11:57:25 +02:00
parent c7b8f5f573
commit 3d9fe12f6f
2 changed files with 8 additions and 20 deletions

View File

@@ -27,14 +27,17 @@ else
TARGET=linux
endif
LDFLAGS=-ldflags="-X main.version=$(APP_VERSION)"
all: $(TARGET)
@echo "Built $(VERSION) @ $(TARGET)"
osx:
GOARCH=$(ARCH) GOOS=darwin go build -o $(PROG)-osx-$(ARCH)
GOARCH=$(ARCH) GOOS=darwin go build $(LDFLAGS) -o $(PROG)-osx-$(ARCH)
linux:
GOARCH=$(ARCH) GOOS=linux go build -o $(PROG)-linux-$(ARCH)
GOARCH=$(ARCH) GOOS=linux go build $(LDFLAGS) -o $(PROG)-linux-$(ARCH)
build_server:

View File

@@ -1,10 +1,8 @@
package main
import (
"strings"
import ()
"github.com/GeertJohan/go.rice"
)
var version = "unknown"
// Gather application status information
type AppStatus struct {
@@ -15,20 +13,7 @@ type AppStatus struct {
// on backends.
func NewAppStatus() (*AppStatus, error) {
status := &AppStatus{
Version: statusGetVersion(),
Version: version,
}
return status, nil
}
// Get application version
func statusGetVersion() string {
meta, err := rice.FindBox("../")
if err != nil {
return "unknown"
}
version, err := meta.String("VERSION")
if err != nil {
return "unknown"
}
return strings.Trim(version, "\n")
}