title: How to get the name of a function in Go?
body: <p>Given a function, is it possible to get its name? Say:</p>
  
  <pre><code>func foo() {
  }
  
  func GetFunctionName(i interface{}) string {
      // ...
  }
  
  func main() {
      // Will print "name: foo"
      fmt.Println("name:", GetFunctionName(foo))
  }
  </code></pre>
  
  <p>I was told that <a href="http://golang.org/pkg/runtime/#Func.FuncForPC" rel="noreferrer">runtime.FuncForPC</a> would help, but I failed to understand how to use it.</p>