title: I have two Go functions that I'd expect to behave the same, but give different results. Trying to understand why
body: <p>I was writing a binary search tree traversal when I came across a problem, and then a slight syntax change fixed it but I don't understand why it wasn't working in the first palce. The two code examples I provide I would expect to run the exact same way but they don't.</p>
  <p>One sets the curr variable to it's left node curr.left, then recursively calls the InOrderRecursive, while the other calls InOrderRecursive directly on curr.left itself.</p>
  <pre><code>type BST struct {
      value int
      left *BST
      right *BST
  }
  </code></pre>
  <p>Does not work (This does return but with the wrong values):</p>
  <pre><code>func (tree *BST) InOrderRecursive(values []int) []int {
      curr := tree
  
      if curr.left != nil {
          curr = curr.left
          values = curr.InOrderRecursive(values)
      }
      values = append(values, curr.value)
      if curr.right != nil {
          curr = curr.right
          values = curr.InOrderRecursive(values)
      }
      return values
  }
  </code></pre>
  <p>Works (returns the correct values):</p>
  <pre><code>func (tree *BST) InOrderRecursive(values []int) []int {
      curr := tree
  
      if curr.left != nil {
          values = curr.left.InOrderRecursive(values)
      }
      values = append(values, curr.value)
      if curr.right != nil {
          values = curr.right.InOrderRecursive(values)
      }
      return values
  }
  </code></pre>
  <p>Could someone please explain the difference in these two code examples and the reason for the different behavior?</p>