Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/earthboundkid/versioninfo

Importable package that parses version info from debug.ReadBuildInfo().
https://github.com/earthboundkid/versioninfo

git go golang version-control-system versioning versions

Last synced: 7 days ago
JSON representation

Importable package that parses version info from debug.ReadBuildInfo().

Awesome Lists containing this project

README

        

# versioninfo [![GoDoc](https://godoc.org/github.com/earthboundkid/versioninfo?status.svg)](https://godoc.org/github.com/earthboundkid/versioninfo/v2) [![Go Report Card](https://goreportcard.com/badge/github.com/earthboundkid/versioninfo/v2)](https://goreportcard.com/report/github.com/earthboundkid/versioninfo/v2)

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

## Examples

```go
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()`:

```go
package main

import (
"fmt"

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

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

Add the `-v` and `-version` flags:

```go
package main

import (
"flag"
"fmt"

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

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