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: 2 months 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 (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-11T00:35:39.000Z (7 months ago)
- Last Synced: 2025-04-04T01:09:33.981Z (2 months 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: 282
- Watchers: 4
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# versioninfo [](https://godoc.org/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")
}
```