V
V
Vladimir Grabko2016-09-14 00:05:03
go
Vladimir Grabko, 2016-09-14 00:05:03

How to find out how many fields are in a structure?

Let's admit there is a code if in Field to transfer number more than an amount of fields there will be a panic. I still do not understand how to find out how many fields there are in general.
reflect.TypeOf(s).Field(2)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
evnuh, 2016-09-14
@VGrabko

https://golang.org/pkg/reflect/#Value.NumField

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question