title: is it possible to make a type-generic (template) function in Golang
body: <p>I'm new to go - just playing with it - but I've written a command line tool - I call about 30 different functions that <code>return x, err</code>.  In every case - what I want to do is just panic if there is an error - basically everything works perfectly, or the whole thing fails.</p>
  
  <p>I know there's <code>template.Must( t Template*, err Error) Template*</code> - and I know I can make a <code>check(something interface{}, err Error) interface{}</code> - but to use it I've gotta do a type cast, which is nasty.</p>
  
  <p>Is it in any way possible to make a sort of generic function <code>panicIfError</code> such that I can do something like</p>
  
  <pre><code> x := panicIfError( ioutil.ReadFile( fileName )) 
  </code></pre>
  
  <p>and have x come out with the right type?</p>
  
  <p>(I've seen lots of people put the if on the same line - to my mind that sacrifices too much readability - currently my only solution is to make an overload of <code>panicIfError</code> for every single type I use, which is not ideal)</p>