Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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().
- Host: GitHub
- URL: https://github.com/earthboundkid/versioninfo
- Owner: earthboundkid
- License: mit
- Created: 2021-11-08T18:14:39.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-11T00:35:39.000Z (2 months ago)
- Last Synced: 2025-01-08T09:02:29.186Z (14 days ago)
- Topics: git, go, golang, version-control-system, versioning, versions
- Language: Go
- Homepage: https://blog.carlana.net/post/2023/golang-git-hash-how-to/
- Size: 14.6 KB
- Stars: 261
- Watchers: 5
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
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 mainimport (
"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 mainimport (
"fmt""github.com/earthboundkid/versioninfo/v2"
)func main() {
fmt.Println("ShortInfo:", versioninfo.Short())
}
```Add the `-v` and `-version` flags:
```go
package mainimport (
"flag"
"fmt""github.com/earthboundkid/versioninfo/v2"
)func main() {
versioninfo.AddFlag(nil)
flag.Parse()
fmt.Println("done")
}
```