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:
@@ -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:
|
||||
|
@@ -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")
|
||||
}
|
||||
|
Reference in New Issue
Block a user