Browse Source

Adjust trim package name strategy

pull/52/head
RPRX 4 years ago committed by GitHub
parent
commit
5a43fa750d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      common/errors/errors.go

12
common/errors/errors.go

@ -36,12 +36,16 @@ func (err *Error) WithPathObj(obj interface{}) *Error {
}
func (err *Error) pkgPath() string {
if err.pathObj != nil {
if p := reflect.TypeOf(err.pathObj).PkgPath(); !strings.HasPrefix(p, "main") {
return p[trim:]
if err.pathObj == nil {
return ""
}
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().

Loading…
Cancel
Save