Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Go package that embeds a git tag/version string in your application

License

NotificationsYou must be signed in to change notification settings

aletheia7/gogitver

Repository files navigation

gogitver andmage (go make)

A go package that inserts a git tag into your binary. Uses mage to efficientlycompile your go application when the git tag changes. Other source code changeswill still trigger a compile. The git version/tag is created beforehand with:

git tag -a# View the git tag:git describe --tags --long# Instead of "go install" execute:mage

Install andmage

gogitver must be installed as a package under your application maindirectory. E.g. if your application resides under ~/go/src/app,gogitver must be installed under ~/go/src/app/gogitver. ~/go/src/app/vendor/gogitveris preferred.

# Examplemkdir~/go/src/app/vendor/gogitvercd~/go/src/appgit clone --depth 1 https://github.com/aletheia7/gogitver.git vendor/gogitverrm -fr vendor/gogitver/.git# link mage_gogitver.goln -s vendor/gogitver/mage_gogitver.go.Add a mg.Dep(Gogitver) to your main magefile.go that should reside under~/go/src/app.

Create a git tag:

git tag -a 1.0.7

Run mage:

mage

gogitver andGNUMake

A go package that inserts a git tag into your binary. Uses make to efficientlycompile your go application when the git tag changes. Other source code changeswill still trigger a compile. The git version/tag is created beforehand with:

git tag -a# View the git tag:git describe --tags --long# Instead of "go install" execute:make# Run "go install" and strip to remove debug symbols:make strip# Instead of "go clean" execute:make clean

Install andGNUMake

gogitver must be installed as a package under your application maindirectory. E.g. if your application resides under ~/go/src/app,gogitver must be installed under ~/go/src/app/gogitver. ~/go/src/app/vendor/gogitveris preferred.

# Examplemkdir~/go/src/app/vendor/gogitvercd~/go/src/appgit clone --depth 1 https://github.com/aletheia7/gogitver.git vendor/gogitverrm -fr vendor/gogitver/.git# link makefileln -s vendor/gogitver/makefile.

Create a git tag:

git tag -a 1.0.7

Run make:

make

GNUMake

Software Version Guidelines:Semantic Versioning

Compare & parse semver version strings:godoc go-semver,code: go-semver

Example

package mainimport ("fmt"// Do not use "github.com/alethiea7/gogitver"// It will not work"app/gogitver")funcmain() {fmt.Println(gogitver.Git())fmt.Println(gogitver.Tag())}
Ouput
1.0.7-0-g8e9e07b1.0.7

License

Use of this source code is governed by a BSD-2-Clause license that can be foundin the LICENSE file.

BSD-2-Clause License

About

Go package that embeds a git tag/version string in your application

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp