callers_go1.21.go 301 B

1234567891011121314151617
  1. //go:build go1.21
  2. package log
  3. import (
  4. "runtime/debug"
  5. "sync"
  6. )
  7. // Reads the build info to get the true full import path for the main package.
  8. var mainPackagePath = sync.OnceValue(func() string {
  9. info, ok := debug.ReadBuildInfo()
  10. if ok {
  11. return info.Path
  12. }
  13. return mainPackageFrameImport
  14. })