@@ -724,7 +724,7 @@ func main() {
724
724
fmt.Println (string (articleBytes)) // 以下是通过json-filter 过滤后的json,此输出是article接口下的json
725
725
// {"avatar":"avatar","nickname":"boyan","uid":1}
726
726
727
- // filter.SelectMarshal 是一个方便测试查看的方法,先过滤,然后再编码成json字符串返回,有错误直接panic,三部操作一气呵成,适合测试查看等
727
+ // filter.SelectMarshal.MustJSON() 是一个方便测试查看的方法,先过滤,然后再编码成json字符串返回,有错误直接panic,三部操作一气呵成,适合测试查看等
728
728
// 下面为了方便演示,将使用SelectMarshal api来进行
729
729
fmt.Println (filter.SelectMarshal (" article" , user).MustJSON ()) // 以下是通过json-filter 过滤后的json,此输出是article接口下的json
730
730
// {"avatar":"avatar","nickname":"boyan","uid":1}
@@ -1159,12 +1159,12 @@ type User struct {
1159
1159
1160
1160
func (u User ) ArticleResp () interface {} {
1161
1161
// 这样当你后面想要优化性能时可以在这里进行优化,
1162
- return filter.SelectMarshal (" article" ,u). Interface ( )
1162
+ return filter.Select (" article" ,u)
1163
1163
}
1164
1164
1165
1165
func (u User ) ProfileResp () interface {} {
1166
1166
// 这样当你后面想要优化性能时可以在这里进行优化,
1167
- return filter.SelectMarshal (" profile" ,u). Interface ( )
1167
+ return filter.Select (" profile" ,u)
1168
1168
}
1169
1169
1170
1170
func (u User ) ChatResp () interface {} {
@@ -1194,7 +1194,7 @@ type User struct {
1194
1194
}
1195
1195
1196
1196
func (u User ) FilterProfile () interface {} {
1197
- return filter.SelectMarshal (" profile" , u). Interface ( )
1197
+ return filter.Select (" profile" , u)
1198
1198
}
1199
1199
1200
1200
func main () {
@@ -1253,7 +1253,7 @@ func UserRes(c *gin.Context) {
1253
1253
Avatar: " avatar" ,
1254
1254
}
1255
1255
1256
- OkWithData (filter.SelectMarshal (" profile" , user). Interface ( ), c)
1256
+ OkWithData (filter.Select (" profile" , user), c)
1257
1257
}
1258
1258
```
1259
1259
0 commit comments