gitcgen

command module
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2020 License: MIT Imports: 6 Imported by: 0

README

Latest Git Commit Id Generator

generate a go file contains a git commit id.

It is good to generate a go file in a go http server project, that the http server can publish a url to show it's version.

Install

Using go get

go get github.com/pharosnet/gitcgen@v1.2.0

Using download

Usage

Commands
Name short Name Desc
show s show latest git commit id
gen g generate a go file contains latest git commit id
show command args:
Name Short Name Value Desc
work_tree w string the path of git project

gen command args:

Name Short Name Value Desc
work_tree w string the path of git project
output o string the file path of generated go file, such as "./foo/bar.go"
short s bool use short git commit id. default is true.
Examples:

Show latest git commit id

gitcgen show -w="{TARGET_GIT_PROJECT_LOCAL_PATH}"

Generate a go file

gitcgen gen -w="{TARGET_GIT_PROJECT_LOCAL_PATH}" -o="./foo/bar.go"

Using in go generate

//go:generate gitcgen gen -w="./" -o="./versions/git_latest_commit_id.go"
func main() {
    // ...
}

Advance

Using it in CI / CD.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL