Adjust trim package name strategy

This commit is contained in:
RPRX 2020-12-05 04:39:58 +00:00 committed by GitHub
parent 32e7cd80e8
commit 5a43fa750d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,12 +36,16 @@ func (err *Error) WithPathObj(obj interface{}) *Error {
} }
func (err *Error) pkgPath() string { func (err *Error) pkgPath() string {
if err.pathObj != nil { if err.pathObj == nil {
if p := reflect.TypeOf(err.pathObj).PkgPath(); !strings.HasPrefix(p, "main") { return ""
return p[trim:] }
path := reflect.TypeOf(err.pathObj).PkgPath()
for i := 0; i < len(path); i++ {
if path[i] == '/' {
return path[trim:]
} }
} }
return "" return path
} }
// Error implements error.Error(). // Error implements error.Error().