title: Format a float to n decimal places and no trailing zeros
body: <p>I want to display a float with the entire integer part and up to two decimals for the fractional part, without trailing zeros.</p>
  
  <p><a href="http://play.golang.org/p/mAdQl6erWX" rel="noreferrer">http://play.golang.org/p/mAdQl6erWX</a>:</p>
  
  <pre><code>// Desired output: 
  // "1.9"
  // "10.9"
  // "100.9"
  
  fmt.Println("2g:")
  fmt.Println(fmt.Sprintf("%.2g", 1.900)) // outputs "1.9"
  fmt.Println(fmt.Sprintf("%.2g", 10.900)) // outputs "11"
  fmt.Println(fmt.Sprintf("%.2g", 100.900)) // outputs "1e+02"
  
  fmt.Println("\n2f:")
  fmt.Println(fmt.Sprintf("%.2f", 1.900)) // outputs "1.90"
  fmt.Println(fmt.Sprintf("%.2f", 10.900)) // outputs "10.90"
  fmt.Println(fmt.Sprintf("%.2f", 100.900)) // outputs "100.90"
  </code></pre>
  
  <p>Formatting with <code>2g</code> has the problem that it starts rounding when the integer increases order of magnitudes. Also, it sometimes displays numbers with an <code>e</code>.</p>
  
  <p>Formatting with <code>2f</code> has the problem that it will display trailing zeros. I could write a post-processing function that removes trailing zeros, but I rather do this with <code>Sprintf</code>.</p>
  
  <p>Can this be done in a generic way using <code>Sprintf</code>?<br>
  If not, what's a good way to do this?</p>