From 8f6f9865d49d044e2fdc5e97bb0cc4fac155162e Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Sat, 16 Jan 2021 12:52:33 -0700 Subject: cmd: Print more detailed version with --environ --- cmd/main.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'cmd/main.go') diff --git a/cmd/main.go b/cmd/main.go index 2dfb867..5643431 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -415,7 +415,7 @@ func printEnvironment() { fmt.Printf("caddy.AppDataDir=%s\n", caddy.AppDataDir()) fmt.Printf("caddy.AppConfigDir=%s\n", caddy.AppConfigDir()) fmt.Printf("caddy.ConfigAutosavePath=%s\n", caddy.ConfigAutosavePath) - fmt.Printf("caddy.Version=%s\n", caddy.GoModule().Version) + fmt.Printf("caddy.Version=%s\n", caddyVersion()) fmt.Printf("runtime.GOOS=%s\n", runtime.GOOS) fmt.Printf("runtime.GOARCH=%s\n", runtime.GOARCH) fmt.Printf("runtime.Compiler=%s\n", runtime.Compiler) @@ -432,6 +432,25 @@ func printEnvironment() { } } +// caddyVersion returns a detailed version string, if available. +func caddyVersion() string { + goModule := caddy.GoModule() + ver := goModule.Version + if goModule.Sum != "" { + ver += " " + goModule.Sum + } + if goModule.Replace != nil { + ver += " => " + goModule.Replace.Path + if goModule.Replace.Version != "" { + ver += "@" + goModule.Replace.Version + } + if goModule.Replace.Sum != "" { + ver += " " + goModule.Replace.Sum + } + } + return ver +} + // moveStorage moves the old default dataDir to the new default dataDir. // TODO: This is TEMPORARY until the release candidates. func moveStorage() { -- cgit v1.2.3