decodeEventDataToPosts 解析事件数据为 Post 结构体
(data interface{}, posts *Post)
| 140 | |
| 141 | // decodeEventDataToPosts 解析事件数据为 Post 结构体 |
| 142 | func decodeEventDataToPost(data interface{}, posts *Post) error { |
| 143 | config := &mapstructure.DecoderConfig{ |
| 144 | Result: posts, |
| 145 | TagName: "mapstructure", |
| 146 | WeaklyTypedInput: true, |
| 147 | DecodeHook: mapstructure.ComposeDecodeHookFunc( |
| 148 | stringToTimeHookFunc("2006-01-02 15:04:05.999"), |
| 149 | stringToNullTimeHookFunc("2006-01-02 15:04:05.999"), |
| 150 | ), |
| 151 | } |
| 152 | |
| 153 | decoder, err := mapstructure.NewDecoder(config) |
| 154 | if err != nil { |
| 155 | return err |
| 156 | } |
| 157 | |
| 158 | return decoder.Decode(data) |
| 159 | } |
| 160 | |
| 161 | // decodeEventDataToUser 解析事件数据为 User 结构体 |
| 162 | func decodeEventDataToUser(data interface{}, users *User) error { |
no test coverage detected