Skip to content
Carl Johnson edited this page Jun 25, 2022 · 1 revision

Welcome to the versioninfo wiki!

How versioninfo gets revision information from Go

TODO

Tips and tricks

How to add a command line flag to print out custom version information

package main

import (
	"flag"
	"fmt"
	"os"
	"github.com/carlmjohnson/flagx"
	"github.com/carlmjohnson/versioninfo"
)

func main() {
	flagx.BoolFunc(nil, "version", "Print version and exit", myPrint)
	flag.Parse()
}

func myPrint() error {
	fmt.Println("My app version is", versioninfo.Short())
	os.Exit(0)
	panic("unreachable")
}
Clone this wiki locally