Traversal inorder Golang

type TreeNode struct {
  Val int
  Left *TreeNode
  Right *TreeNode
}

func inOrderTraverse(root *TreeNode) int[] {
  list := []int {}
  if root == nil {
    return list
  }
  
  stack := []*TreeNode { }
  for root != nil || len(stack) > 0 {
    
    for root != nil {
      stack = append(stack, root)
      root = root.Left
    }
    
    root = stack[len(stack) - 1]
    stack = stack[0:len(stack) - 1]
    list = append(list, root.Val)
    root = root.Right
  }
  
  return list
}

Ibrahim Albarghouthi