appendStructField appends the field and value held by the structure v to dst, and returns the appended dst.
(dst []interface{}, v reflect.Value)
| 109 | |
| 110 | // appendStructField appends the field and value held by the structure v to dst, and returns the appended dst. |
| 111 | func appendStructField(dst []interface{}, v reflect.Value) []interface{} { |
| 112 | typ := v.Type() |
| 113 | for i := 0; i < typ.NumField(); i++ { |
| 114 | tag := typ.Field(i).Tag.Get("redis") |
| 115 | if tag == "" || tag == "-" { |
| 116 | continue |
| 117 | } |
| 118 | name, opt, _ := strings.Cut(tag, ",") |
| 119 | if name == "" { |
| 120 | continue |
| 121 | } |
| 122 | |
| 123 | field := v.Field(i) |
| 124 | |
| 125 | // miss field |
| 126 | if omitEmpty(opt) && isEmptyValue(field) { |
| 127 | continue |
| 128 | } |
| 129 | |
| 130 | if field.CanInterface() { |
| 131 | dst = append(dst, name, field.Interface()) |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | return dst |
| 136 | } |
| 137 | |
| 138 | func omitEmpty(opt string) bool { |
| 139 | for opt != "" { |
no test coverage detected