gitee.com/sy_183/go-common@v1.0.5-0.20231205030221-958cfe129b47/errors/not-found.go (about) 1 package errors 2 3 import "fmt" 4 5 type NotFound struct { 6 Target any 7 } 8 9 func NewNotFound(target any) NotFound { 10 return NotFound{Target: target} 11 } 12 13 func (e NotFound) Error() string { 14 switch re := e.Target.(type) { 15 case error: 16 return fmt.Sprintf("[%s]未找到", re.Error()) 17 case string: 18 return fmt.Sprintf("[%s]未找到", re) 19 case fmt.Stringer: 20 return fmt.Sprintf("[%s]未找到", re.String()) 21 default: 22 return fmt.Sprintf("[%v]未找到", re) 23 } 24 }