Binary search tree implementation in golang
Some quick remarks:


The type BNode is public, but the insert function isn't. This is quite strange.
insert(null, 0) causes a panic. That's no good.
&amp;BNode{data: data, left: nil, right: nil} can be just &amp;BNode{data: data} since the default value for a pointer is null.
How would someone use a tree once you've added members to it? I'm guessing you have more functions than just insert, so would be good to share these as well.


You may want to have a separate type for the tree (that just contains a root) - this is a clean way of handling the empty tree case. In addition, insert seems more suitable as a method rather than a function, bringing the final result to something like this:

type BTree struct {
    root  *node
}

type node struct {
    left  *node
    right *node
    data  int64
}

func (t *BTree) Insert(data int64) {
    if t.root == nil {
        t.root = &amp;node{data: data}
    } else {
        t.root.insert(data)
    }
}

func (n *node) insert(data int64) {
    if data &lt;= n.data {
        if n.left == nil {
            n.left = &amp;node{data: data}
        } else {
            n.left.insert(data)
        }
    } else {
        if n.right == nil {
            n.right = &amp;node{data: data}
        } else {
            n.right.insert(data)
        }
    }
}


Usage:

var tree BTree
tree.insert(50)