Removing fields from struct or hiding them in JSON Response

后端 未结 13 1409
孤街浪徒
孤街浪徒 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:31

    The question is now a bit old, but I came across the same issue a little while ago, and as I found no easy way to do this, I built a library fulfilling this purpose. It allows to easily generate a map[string]interface{} from a static struct.

    https://github.com/tuvistavie/structomap

提交回复
热议问题