title: Preferred way to instantiate types in Go
body: <p>I like the fact that Go doesn't give me a million ways to do simple things – to borrow from The Zen of Python, “There should be one – and preferably only one – obvious way to do it.”</p>
  
  <p>However, I'm not clear on the preferred/idiomatic way of instantiating types. The basic types are easy:</p>
  
  <pre><code>n := 0
  t := 1.5
  str := "Hello"
  </code></pre>
  
  <p>But what about structs? Are the following equivalent, and if so, which is preferred and why?</p>
  
  <pre><code>var f Foo    
  f := Foo{}
  </code></pre>
  
  <p>What about slices? I can do <code>var xs []int</code>, <code>xs := []int{}</code>, or <code>xs := make([]int)</code>, but I think the first option (as opposed to with structs) is different from the others? I assume this will also apply to maps.</p>
  
  <p>With pointers, I hear that <code>new</code> should be avoided. Is this good advice, and if so, what would count as a valid usage of <code>new</code>?</p>
  
  <p>I realize that this may partly be a question of style, but a rationale for preferring a particular style would be helpful in any case.</p>