Removing fields from struct or hiding them in JSON Response

后端 未结 13 1388
孤街浪徒
孤街浪徒 2020-12-12 09:37

I\'ve created an API in Go that, upon being called, performs a query, creates an instance of a struct, and then encodes that struct as JSON before sending back to the caller

13条回答
  •  攒了一身酷
    2020-12-12 10:09

    You can use tagging attribute "omitifempty" or make optional fields pointers and leave those you want skipped uninitialized.

提交回复
热议问题