Is it possible to add properties to an empty struct?


Once a struct is declared

type M struct{}

is it possible to later add properties to the struct so it can become something like

type M struct{
  name string

by using some function that would modify the original struct?


No, types can not be changed. (Other than by changing the source and recompiling.)

1 Like

No, but you can maybe use map.

1 Like

Agreed. The OP sounds like need map instead of struct.

Thanks all! I’ll see where I get to using a map instead :slight_smile: .


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.