douxu3315
douxu3315
2018-02-07 11:52

如何列出指向golang结构所有字段的指针?

  • struct

Is there a good way in golang to pass all fields of some struct instance c?

I'm looking for some syntactic sugar functionality, so that instead of doing this:

method(&c.field1, &c.field2, &c.field3, &c.field4, &c.field5, ...)

I could do this:

method(FieldsPointers(c)...)

I'm rather new to golang and still learning the basics, if there is no good way to do what I want for a good reason, I'd appreciate an explanation as to why.

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐

换一换