Hi, I am having trouble to add default implementation of an interface, to
simulate inheritance. The concept is similar to java's abstract class
default implementation. But I don't know the right approach in Go.
For example, I want to build a graph of servers, on different racks and
data centers.
Currently, I have these code:
type Node struct{
parent *Node
children []*Node
}
//several default function implementations
func (*Node) AddChild(){
...
}
type Server struct {
Node
ipAddress string
...
}
type Rack struct {
Node
ipAddressRange string
...
}
type DataCenter struct {
Node
ipAddressRange string
...
}
However, server.Node.parent is a *Node, and can not be converted to a Rack
object.
Chris
http://weed-fs.googlecode.com