I am trying to use Interfaces and Struct in GoLang to create a binary tree concept
I wrote the below code
package main
import "fmt"
type node interface {
add(a int)
getval() int
}
type node_element struct {
element int
left *node
right *node
}
func (c *node_element) add(a int) {
c.element = a
}
func (c *node_element) getval() int {
return c.element
}
func main() {
var s node
s = &node_element{}
s.add(1)
fmt.Println(s.getval())
}
Now how do I instantiate left and right. I am using VIM with Go autocomplete. In auto complete on pressing . there is no list. Which means access to this pointer object to s is not happening
How to instantiate and use left and right ?