Implemented a package for storing program's version.
This commit is contained in:
parent
23b570c4e5
commit
cdabb77c39
4
Makefile
4
Makefile
@ -5,10 +5,10 @@ SYSDDIR=${SYSDDIR_:/%=%}
|
||||
DESTDIR:=
|
||||
PREFIX:=/usr/local
|
||||
|
||||
VERSION=24.27.0
|
||||
VERSION?=24.27.0
|
||||
|
||||
FLAGS:=-buildmode=pie -modcacherw -mod=readonly -trimpath
|
||||
LDFLAGS=-ldflags "-s -w -X main.version=${VERSION}" -tags osusergo,netgo
|
||||
LDFLAGS=-ldflags "-s -w -X 'git.arav.su/Arav/dwelling-home/internal/version.ver=v${VERSION}'" -tags osusergo,netgo
|
||||
|
||||
.PHONY: run install uninstall clean
|
||||
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"time"
|
||||
|
||||
dwhttp "git.arav.su/Arav/dwelling-home/internal/http"
|
||||
"git.arav.su/Arav/dwelling-home/internal/version"
|
||||
mfsqlite "git.arav.su/Arav/dwelling-home/pkg/mindflow/database/sqlite"
|
||||
"git.arav.su/Arav/dwelling-home/web"
|
||||
"git.arav.su/Arav/httpr"
|
||||
@ -19,8 +20,6 @@ import (
|
||||
"github.com/a-h/templ"
|
||||
)
|
||||
|
||||
var version string
|
||||
|
||||
var (
|
||||
showVersion = flag.Bool("v", false, "show version")
|
||||
listenAddress = flag.String("listen", "/var/run/dwelling-home/sock", "listen address (ip:port|unix_path)")
|
||||
@ -34,7 +33,7 @@ func main() {
|
||||
flag.Parse()
|
||||
|
||||
if *showVersion {
|
||||
fmt.Println("dwelling-home Ver.", version, "\nCopyright (c) 2023 Alexander \"Arav\" Andreev <me@arav.su>")
|
||||
fmt.Println("dwelling-home", version.GetVersion(), "\nCopyright (c) 2023,2024 Alexander \"Arav\" Andreev <me@arav.su>")
|
||||
return
|
||||
}
|
||||
|
||||
|
7
internal/version/version.go
Normal file
7
internal/version/version.go
Normal file
@ -0,0 +1,7 @@
|
||||
package version
|
||||
|
||||
var ver string
|
||||
|
||||
func GetVersion() string {
|
||||
return ver
|
||||
}
|
Loading…
Reference in New Issue
Block a user