All notable changes to this project are documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
buildinfo-slog,buildinfo-zap, andbuildinfo-otelnow emit the build provenance added in 0.1.2:build_source(slog, zap) andbuild.source/KeySource(otel). These three adapters enumerate fields by hand, so a new core field reaches logs and traces only when they are updated — the failure mode is a silently missing key rather than a compile error, so each now has a test asserting the key is present and holds a validbuildinfo.Source. The HTTP adapters serialize viaInfo.JSONand picked the field up automatically.
- All eight
contrib/adapters now requiregithub.com/ubgo/buildinfov0.1.2.
Info.Sourcereports which input producedInfo.Version:SourceLdflags(stamped by the release pipeline),SourceModule(resolved bygo install pkg@version), orSourceUnknown(a plaingo build/go run/go test). The version string alone is ambiguous — a binary reportsdevboth when built locally and when a release pipeline silently failed to pass its ldflags — and those need different responses.Sourceis assigned in the same statement asVersionat every site, so the two cannot drift.Source.Valid()andSource.String().Info.HasVersion()reports whetherVersioncame from a real input, equivalent toSource != SourceUnknown.Info.HasCommit()reports whetherCommitholds a real hash rather than theUnknownsentinel. Check it before renderingModified:"unknown (dirty)"asserts a dirty checkout for a build that carries no VCS record at all.- Exported sentinels
DevVersion("dev") andUnknown("unknown"). Consumers previously had to hardcode these literals or duplicate them as private constants, which breaks silently if this package ever changes one. sourcekey inMap()output and"source"field inInfo.JSON().
- The
"dev"and"unknown"literals insideload()now reference the exported sentinel constants, so there is a single definition of each. - Package and
Infodocumentation expanded: every field carries its own doc comment, and the package doc gains Provenance and Dependencies sections.
releaseworkflow supportsworkflow_dispatchwith an existing tag, for tags pushed before the workflow existed or when a push-triggered run needs re-running. Deleting and re-pushing a tag is not an option once the module proxy has cached it. Note that GitHub does not trigger push-tag workflows when more than three tags arrive in one push — release tags must be pushed in batches of three or fewer, or dispatched manually.releaseworkflow: pushing a release tag runs that module's vet + race tests and, on success, creates the GitHub Release with notes taken from this file. Handles both tag shapes in this repo —vX.Y.Zfor the core module andcontrib/<adapter>/vX.Y.Zfor adapters — deriving the module directory from the tag. Notes are passed via--notes-fileand every value reaches the shell throughenv:, never through inline${{ }}expansion, so backticks in CHANGELOG prose cannot be command-substituted into the release body. Only the core module quotes the root CHANGELOG; adapters share that file and their versions collide with core's, so they get generic notes. Re-running a tag updates its existing release rather than failing. There is no auto-bump-on-merge path: cutting a library version stays a deliberate act.
- All eight
contrib/adapters now requiregithub.com/ubgo/buildinfo v0.1.1, so consumers importing an adapter pick up theMain.Versionfallback without an explicitgo get -uof the core module.
Info.Versionnow falls back toruntime/debug.BuildInfo.Main.Versionwhen no-ldflagsoverride is set, so binaries installed viago install pkg@versionreport the resolved module version instead of the"dev"sentinel. The(devel)placeholder reported for locally built binaries is treated as absent, preserving the previous"dev"behaviour forgo build/go run/go test.-ldflagsoverrides continue to win.
- Initial implementation of the
buildinfocore module:Info,Module,Get,Map,Info.JSON. -ldflagsoverrides forVersion,Commit,BuildTime,Branch.- Auto-population of
GoVersion,GOOS,GOARCH,Modified,Modulesviaruntime/debug.ReadBuildInfo. - Sentinel default values (
"dev","unknown") for empty fields. - Test suite with 100% statement coverage covering ldflags precedence, VCS fallback, replace-resolution, JSON round-trip, and Map shape.
- Eight adapter modules under
contrib/:buildinfo-nethttp— stdlibnet/http/versionhandler + Mount helper.buildinfo-gin— Gin handler + Mount helper.buildinfo-chi— Chi Mount helper using stdlibhttp.Handler.buildinfo-echo— Echo handler + Mount helper.buildinfo-fiber— Fiber handler + Mount helper.buildinfo-otel— OpenTelemetry resource attributes viaAttributes().buildinfo-zap— Zap log fields viaFields()andNamespace().buildinfo-slog— stdlibslogAttrs viaAttrs()andGroup().
- Each adapter ships its own Go module with its own
go.mod, so consumers only download dependencies of the adapters they import. - Every adapter exposes a uniform API:
Handler,Mount(router, ...)withWithPathandWithMiddlewareoptions for HTTP renderers;Fields/Attrs/Attributesfor logging and observability adapters. - Taskfile, CI workflows, README, CONTRIBUTING, NOTICE.
- Licensed under Apache License 2.0.