Some ways to do it: https://play.golang.org/p/sg08Buv-E3-
Note that arrays are rarely used in Go. When in doubt, default to using a slice. I provided slice examples as well. If you want to initialize a very large array or slice to a value other than the zero value, you could also use a loop. On Wednesday, July 14, 2021 at 11:32:13 AM UTC-4 trivedi...@gmail.com wrote: > Hi all, it would be helpful for me if a small doubt of mine is resolved. > > I want to know how to create an array of structure instances for a nested > structure. Let me write it > > type Strct1 struct { > val1 int > val2 int > } > type Strct2 struct { > Namce string > temp Strct1 > } > I want to create an array of instances for Strct2 and initialise it. > Please let me know how to do it. > > Thanks > Nagaraj > > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/82a85bf1-a2ac-4e35-a40e-00fb7d337ba2n%40googlegroups.com.