I have a struct which implements an interface - hence I can assign that struct to a variable of said interface.
But I'd like to create a type which maps from string -> Whoa interface, but to be able to use a concrete struct when initializing. This doesn't work, I'm getting:
cannot use (map[string]Boom literal) (value of type map[string]Boom) as poppa value in variable declaration
Any help appreciated!
package main
type Whoa interface {
yes()
}
type Boom struct {
hey string
}
func (b Boom) yes() {
}
type poppa map[string]Whoa
func main() {
var thisWorks Whoa = Boom{}
var thisDoesnt poppa = map[string]Boom{}
}
map[string]Boom{}to the variable with concrete typepoppa(amap[string]Whoa). The map values have different representations in memory. Write code to copy themap[string]Boom{}to apoppa.