Skip to content

Support setting version string via ldflags#262

Open
p5 wants to merge 1 commit intocaddyserver:masterfrom
p5:dev/p5/xcaddy-version-ldflags
Open

Support setting version string via ldflags#262
p5 wants to merge 1 commit intocaddyserver:masterfrom
p5:dev/p5/xcaddy-version-ldflags

Conversation

@p5
Copy link

@p5 p5 commented Mar 3, 2026

When xcaddy is built directly from source (e.g. distro packaging), Go's debug.ReadBuildInfo() reports the main module version as "(devel)" rather than the actual release version. The upstream build process works around this by building from a separate wrapper module that imports xcaddy as a versioned dependency, but packagers typically build directly from the source tarball.

Add a version variable that can be set via -ldflags -X at build time, allowing packagers to inject the correct version string.


Other Go projects also do similar:

@francislavoie
Copy link
Member

Caddy itself also does this actually, we recently just merged a patch which adds a couple more variables to override some other bits like the binary name for the help stuff in the command etc. Could you match the variable names we used for that in Caddy in here?

When xcaddy is built directly from source (e.g. distro packaging),
Go's debug.ReadBuildInfo() reports the main module version as
"(devel)" rather than the actual release version. The upstream
build process works around this by building from a separate wrapper
module that imports xcaddy as a versioned dependency, but packagers
typically build directly from the source tarball.

Add a CustomVersion variable that can be set via -ldflags -X at
build time, allowing packagers to inject the correct version string.
@p5 p5 force-pushed the dev/p5/xcaddy-version-ldflags branch from 87f4a99 to 127d8c9 Compare March 4, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants