Skip to content

Commit

Permalink
refactor: Length 和 Notlength 现在支持 chan
Browse files Browse the repository at this point in the history
  • Loading branch information
caixw committed Jul 21, 2023
1 parent 928847e commit 383ab1e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var failureSprint FailureSprintFunc = DefaultFailureSprint
// Failure 在断言出错时输出的错误信息
type Failure struct {
Action string // 操作名称,比如 Equal,NotEqual 等方法名称。
Values map[string]interface{} // 断言出错是返回的一些额外参数
Values map[string]interface{} // 断言出错时返回的一些额外参数
User string // 断言出错时用户反馈的额外信息
}

Expand Down Expand Up @@ -79,7 +79,7 @@ func DefaultFailureSprint(f *Failure) string {

// NewFailure 声明 Failure 对象
//
// user 表示用户提交的反馈,其第一个元素如果是 string,那么将调用 fmt.Sprintf(user[0], user[1:]...)
// user 表示用户提交的反馈,其第一个元素如果是 string,那么将调用 fmt.Sprintf(user[0], user[1:]...)
// 对数据进行格式化,否则采用 fmt.Sprint(user...) 格式化数据;
// kv 表示当前错误返回的数据;
func NewFailure(action string, user []interface{}, kv map[string]interface{}) *Failure {
Expand Down
2 changes: 1 addition & 1 deletion util.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func getLen(v interface{}) (l int, msg string) {
}

switch r.Kind() {
case reflect.Array, reflect.String, reflect.Slice, reflect.Map:
case reflect.Array, reflect.String, reflect.Slice, reflect.Map, reflect.Chan:
return r.Len(), ""
}
return 0, fmt.Sprintf("无法获取 %s 类型的长度信息", r.Kind())
Expand Down

0 comments on commit 383ab1e

Please sign in to comment.