package main import "fmt" type Location struct { System, Planet string node_s, node_p *Node } func (l *Location) Type() string { return "Location" } func (l *Location) String() string { return fmt.Sprintf("%s, %s", l.Planet, l.System) } func (l *Location) Parse(node *Node) error { switch node.Key() { case "system": l.System = node.Value() l.node_s = node case "planet": l.Planet = node.Value() l.node_p = node } return nil } func (l *Location) Update() error { if l.node_s == nil || l.node_p == nil { return fmt.Errorf("location invalidated, system or planet node pointers are nil") } l.node_s.SetValue(l.System) l.node_p.SetValue(l.Planet) return nil }