Skip to content

earthboundkid/versioninfo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

versioninfo GoDoc Go Report Card

Importable package that parses debug.ReadBuildInfo() for inclusion in your Go application. Requires Go 1.18+.

Examples

package main

import (
    "fmt"

    "github.com/earthboundkid/versioninfo/v2"
)

func main() {
    fmt.Println("Version:", versioninfo.Version)
    fmt.Println("Revision:", versioninfo.Revision)
    fmt.Println("DirtyBuild:", versioninfo.DirtyBuild)
    fmt.Println("LastCommit:", versioninfo.LastCommit)
}

You may use the concatenated information provided by versioninfo.Short():

package main

import (
    "fmt"

    "github.com/earthboundkid/versioninfo/v2"
)

func main() {
    fmt.Println("ShortInfo:", versioninfo.Short())
}

Add the -v and -version flags:

package main

import (
    "flag"
    "fmt"

    "github.com/earthboundkid/versioninfo/v2"
)

func main() {
    versioninfo.AddFlag(nil)
    flag.Parse()
    fmt.Println("done")
}