No description
Find a file
2025-04-20 12:13:03 +03:00
go.mod Fixed module path in go.mod. 2025-04-20 01:12:50 +03:00
LICENSE First commit. 2025-04-20 01:04:48 +03:00
main.go Short flag detection is added to the code. 2025-04-20 11:40:01 +03:00
README.md README.md file is added. 2025-04-20 12:13:03 +03:00

The "Version" package

============= This package provides --version flag feature to your cli. It recognize both short and long flags. Version number is automatically added from the latest tag in your git repo.

Usage

  1. Download the package by go get command:
go get code.foilhatguy.casa/pub/version
  1. Add the package as a tool dependency to your project, tools.go:
// +build tools

package tools

import (
	_ "code.foilhatguy.casa/pub/version"
)
  1. In the main package add a go:generate directive:
//go:generate go run code.foilhatguy.casa/pub/version
  1. Run code generator by go generate command:
go generate ./...

The package will detect a version number from the latest git tag from your project. Then it will generate a version.go file as a part of the main package. It will contain a version number as a constant and code for --version flag detection. 5. Build and run your application with the --version flag.

go run . --version