Useful Techniques in Go
<p><pre><code>  type T struct {
      Foo string
      Bar int
      Qux string
  }
  
  t := T{"example", 123} // doesn't compile
  t := T{Foo: "example", Bar: 123} // OK
</code></pre>
I find this behavior somewhat surprising. Contrary to the author's claim, I would expect <i>both</i> to fail to compile.<p>Reading the Go specification, it seems to be a valid behavior.<p>> An element list that contains keys does not need to have an element for each struct field. Omitted fields get the zero value for that field.[1]<p>I understand zeroing out the "unused" fields is common in low level programming, but Go's behavior in this specific case feels a bit too implicit for my taste.<p>[1] <a href="https://golang.org/ref/spec" rel="nofollow">https://golang.org/ref/spec</a>