babarot / gomi

🗑️ Replacement for UNIX rm command!
https://babarot.me/gomi
MIT License
316 stars 13 forks source link

Set version with build flags #32

Closed nunotexbsd closed 1 year ago

nunotexbsd commented 1 year ago

Hello,

Trying to set version when building with:

## FreeBSD port
DISTVERSION=    1.1.5
GO_BUILDFLAGS=  -ldflags "\
                -w -s \
                -X github.com/b4b4r07/gomi/Version=${DISTVERSION}"

but gomi --version: unset (unset)

I use this go buildflags on other projects successfully, e.g.:

## gomplate port (https://github.com/hairyhenderson/gomplate)
DISTVERSION=    3.11.4
GO_BUILDFLAGS=  -ldflags "\
                -w -s \
                -X github.com/hairyhenderson/gomplate/v3/version.GitCommit=${GH_TAG_COMMIT} \
                -X github.com/hairyhenderson/gomplate/v3/version.Version=${DISTVERSION}"

Am I missing something?

Thanks

babarot commented 1 year ago

@nunotexbsd

$ go build -ldflags "-s -w -X main.Version=v12.34.56 -X main.Revision=foobar"
$ ./gomi --version
v12.34.56 (foobar)
nunotexbsd commented 1 year ago

@b4b4r07

Fixed!

Does "Revision" have some special meaning or should it be set to "" (empty instead of "unset")?

babarot commented 1 year ago

no problem not to set it. Just friendly info

nunotexbsd commented 1 year ago

Thanks again. https://cgit.freebsd.org/ports/commit/?id=311096e3602e2ff957b95da4ef74fbf3497e29ab