mirror of
https://github.com/caddyserver/caddy.git
synced 2025-06-11 00:13:37 +08:00
Refactor code related to getting current version
And set version in CertMagic for User-Agent purposes
This commit is contained in:
21
cmd/main.go
21
cmd/main.go
@ -9,7 +9,6 @@ import (
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
"runtime/debug"
|
||||
)
|
||||
|
||||
// Main executes the main function of the caddy command.
|
||||
@ -66,23 +65,3 @@ func handlePingbackConn(conn net.Conn, expect []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// getGoBuildModule returns the build info of Caddy
|
||||
// from debug.BuildInfo (requires Go modules). If
|
||||
// no version information is available, a non-nil
|
||||
// value will still be returned, but with an
|
||||
// unknown version.
|
||||
func getGoBuildModule() *debug.Module {
|
||||
bi, ok := debug.ReadBuildInfo()
|
||||
if ok {
|
||||
// The recommended way to build Caddy involves
|
||||
// creating a separate main module, which
|
||||
// TODO: track related Go issue: https://github.com/golang/go/issues/29228
|
||||
for _, mod := range bi.Deps {
|
||||
if mod.Path == "github.com/mholt/caddy" {
|
||||
return mod
|
||||
}
|
||||
}
|
||||
}
|
||||
return &debug.Module{Version: "unknown"}
|
||||
}
|
||||
|
Reference in New Issue
Block a user