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