|
Kevin Gillette |
at Nov 29, 2012 at 6:39 pm
|
⇧ |
| |
What you're suggesting is embedding an unnamed type. Since brace, bracket,
and asterisk characters are not valid identifier characters, you couldn't
access the underlying field anyway --
m := MyMap{}
m.*map[string]interface{}["something"]
That would be a syntax error.
You can embed any unnamed type:
type underlyingmap map[string]interface{}
type MyMap struct {
underlyingmap
SomeField string
}
m := MyMap{}
m.underlyingmap["something"]
The above should work.
On Wednesday, November 28, 2012 4:13:37 PM UTC-7, Dustin Norlander wrote:
Hi,
I've searched all over and can't find the answer to this.
I have a struct I would like to extend a map. Based on what I've read it
should look like :
type MyMap struct {
*map[string]interface{}
SomeField string
}
or possibly this:
type MyMap map[string]interface{} {
SomeField string
}
Neither work. Is there a way to do this?
thanks much,
Dustin
--