title: Hiding nil values, understanding why Go fails here
body: <p>I fail to understand how to correctly assure that something is not <code>nil</code> in this case:</p>
  <pre><code>package main
  
  type shower interface {
    getWater() []shower
  }
  
  type display struct {
    SubDisplay *display
  }
  
  func (d display) getWater() []shower {
    return []shower{display{}, d.SubDisplay}
  }
  
  func main() {
    // SubDisplay will be initialized with null
    s := display{}
    // water := []shower{nil}
    water := s.getWater()
    for _, x := range water {
      if x == nil {
        panic(&quot;everything ok, nil found&quot;)
      }
  
      // First iteration display{} is not nil and will
      // therefore work, on the second iteration
      // x is nil, and getWater panics.
      x.getWater()
    }
  }
  </code></pre>
  <p>The only way I found to check if that value is actually <code>nil</code> is by using reflection.</p>
  <p>Is this really wanted behaviour? Or do I fail to see some major mistake in my code?</p>
  <p><a href="http://play.golang.org/p/jHHXZbLH7e" rel="nofollow noreferrer">Play link here</a></p>