Home > other >  Is it possible to create a Struct with dynamic keys in Golang?
Is it possible to create a Struct with dynamic keys in Golang?

Time:03-14

Just learning Go. I want to create a Struct with different dates as the keys, and value is a Map[string]int. It don't seem possible since all keys should be predefined in a struct.

CodePudding user response:

Is it possible to create a Struct with dynamic keys in Go[...]?

No.

What memory layout would such a thing have and how would you know that at compile time?

  • Related