Cobra doesn't obey the build-time variables
Signed-off-by: Shin'ya Minazuki <shinyoukai@laidback.moe>
This commit is contained in:
2
Makefile
2
Makefile
@@ -1,5 +1,5 @@
|
||||
GO ?= go
|
||||
GOFLAGS ?= -buildvcs=false -ldflags='-w -X code.laidback.moe/yuki.Version=1.0' -buildmode=exe -v
|
||||
GOFLAGS ?= -buildmode=exe -buildvcs=false -v
|
||||
PREFIX ?= /usr/local
|
||||
|
||||
all: build
|
||||
|
||||
@@ -6,10 +6,6 @@ env:
|
||||
GO: go
|
||||
GOTELEMETRY: off
|
||||
|
||||
vars:
|
||||
IMPORT: code.laidback.moe/yuki
|
||||
VERSION: 2026.01.21
|
||||
|
||||
tasks:
|
||||
default:
|
||||
cmds:
|
||||
@@ -17,7 +13,7 @@ tasks:
|
||||
build:
|
||||
desc: Build the interface
|
||||
cmds:
|
||||
- $GO build -v -ldflags='-w -X {{.IMPORT}}.Version={{.VERSION}}' -buildvcs=false -o yuki
|
||||
- $GO build -buildmode=exe -buildvcs=false -v
|
||||
clean:
|
||||
desc: Remove generated files
|
||||
cmds:
|
||||
|
||||
1
root.go
1
root.go
@@ -8,7 +8,6 @@ import (
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "yuki",
|
||||
Short: "An extraterrestial client for WriteFreely",
|
||||
Version: FullVersion(),
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
|
||||
17
version.go
17
version.go
@@ -1,17 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
Revision = "0"
|
||||
Version = "0"
|
||||
)
|
||||
|
||||
func FullVersion() string {
|
||||
return fmt.Sprintf("%s (r%s)", Version, Revision)
|
||||
}
|
||||
func PrintVersion() string {
|
||||
return fmt.Sprintf("%s", Version)
|
||||
}
|
||||
Reference in New Issue
Block a user