Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ import (
"github.com/caddyserver/xcaddy/internal/utils"
)

// CustomVersion is an optional string that overrides xcaddy's
// reported version. It can be helpful when downstream packagers
// need to manually set xcaddy's version, since building as the
// main module causes debug.ReadBuildInfo() to report "(devel)".
//
// Set this variable during `go build` with `-ldflags`:
//
// -ldflags '-X github.com/caddyserver/xcaddy/cmd.CustomVersion=v0.4.4'
//
// for example.
var CustomVersion string

var (
caddyVersion = os.Getenv("CADDY_VERSION")
raceDetector = os.Getenv("XCADDY_RACE_DETECTOR") == "1"
Expand Down Expand Up @@ -207,6 +219,9 @@ func splitWith(arg string) (module, version, replace string, err error) {

// xcaddyVersion returns a detailed version string, if available.
func xcaddyVersion() string {
if CustomVersion != "" {
return CustomVersion
}
mod := goModule()
ver := mod.Version
if mod.Sum != "" {
Expand Down
Loading