|
@ -209,24 +209,23 @@ func (d *Duration) UnmarshalJSON(b []byte) error { |
|
|
// value will still be returned, but with an
|
|
|
// value will still be returned, but with an
|
|
|
// unknown version.
|
|
|
// unknown version.
|
|
|
func GoModule() *debug.Module { |
|
|
func GoModule() *debug.Module { |
|
|
|
|
|
mod := &debug.Module{Version: "unknown"} |
|
|
bi, ok := debug.ReadBuildInfo() |
|
|
bi, ok := debug.ReadBuildInfo() |
|
|
if ok { |
|
|
if ok { |
|
|
|
|
|
mod.Path = bi.Main.Path |
|
|
// The recommended way to build Caddy involves
|
|
|
// The recommended way to build Caddy involves
|
|
|
// creating a separate main module, which
|
|
|
// creating a separate main module, which
|
|
|
// TODO: track related Go issue: https://github.com/golang/go/issues/29228
|
|
|
// TODO: track related Go issue: https://github.com/golang/go/issues/29228
|
|
|
for _, mod := range bi.Deps { |
|
|
// once that issue is fixed, we should just be able to use bi.Main... hopefully.
|
|
|
if mod.Path == goModule { |
|
|
for _, dep := range bi.Deps { |
|
|
return mod |
|
|
if dep.Path == mod.Path { |
|
|
|
|
|
return dep |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return &debug.Module{Version: "unknown"} |
|
|
return mod |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// goModule is the name of this Go module.
|
|
|
|
|
|
// TODO: we should be able to find this at runtime, see https://github.com/golang/go/issues/29228
|
|
|
|
|
|
const goModule = "github.com/caddyserver/caddy/v2" |
|
|
|
|
|
|
|
|
|
|
|
// CtxKey is a value type for use with context.WithValue.
|
|
|
// CtxKey is a value type for use with context.WithValue.
|
|
|
type CtxKey string |
|
|
type CtxKey string |
|
|
|
|
|
|
|
|