Is it possible to access methods that are declared in a type's underlying type? For example, I want a ResourceSet
to be able to call my Set
type's AddId
method .
See: http://play.golang.org/p/Fcg6Ryzb67
package main
type Resource struct {
Id uint32
}
type Set map[uint32]struct{}
func (s Set) AddId(id uint32) {
s[id] = struct{}{}
}
type ResourceSet Set
func (s ResourceSet) Add(resource Resource) {
id := resource.Id
s.AddId(id)
}
func main() {
resource := Resource{Id: 1}
s := ResourceSet{}
s.Add(resource)
}
The error I'm getting is:
s.AddId undefined (type ResourceSet has no field or method AddId)