title: Conditional/optional fields in struct type
body: <p>I have a <code>Node</code> struct type like this:</p>
  
  <pre class="lang-golang prettyprint-override"><code>package tree
  
  // Enum for node category
  type Level int32
  const (
      Leaf Level = iota + 1
      Branch
      Root
  )
  
  type Node struct {
      Children []*Node
      Parent   *Node
      X        float32
      Y        float32
      Z        float32
      Dim      float32
      Category Level
      LeafPenetration float32 // Needed only if category is "Leaf"
      RootPadDim float32      // Needed only if category is "Root"
  }
  </code></pre>
  
  <p>I have two fields of <code>Node</code> which are optional and only needed depending upon <code>category</code> field:</p>
  
  <pre class="lang-golang prettyprint-override"><code>    leafPenetration float32 // Needed only if category is "Leaf"
      rootPadDim float32      // Needed only if category is "Root"
  </code></pre>
  
  <p>Is the current <code>Node</code> implementation fine? What is the best practice for such optional/conditional fields inside struct types?</p>