package e import sysErr "errors" type Error struct { Code string Message string } func (e *Error) Error() string { return e.Message } func NewError(message ...string) *Error { err := &Error{ "1000", "业务错误", } if len(message) == 0 { return err } err.Message = message[0] if len(message) > 1 { err.Code = message[1] } return err } func Is(err error, target error) bool { return sysErr.Is(err, target) }