title: Why can I type alias functions and use them without casting?
body: <p>In Go, if you define a new type e.g.:</p>
  
  <pre><code>type MyInt int
  </code></pre>
  
  <p>You can't then pass a <code>MyInt</code> to a function expecting an int, or vice versa:</p>
  
  <pre><code>func test(i MyInt) {
      //do something with i
  }
  
  func main() {
      anInt := 0
      test(anInt) //doesn't work, int is not of type MyInt
  }
  </code></pre>
  
  <p>Fine. But why is it then that the same does not apply to functions? e.g.:</p>
  
  <pre><code>type MyFunc func(i int)
  func (m MyFunc) Run(i int) {
      m(i)
  }
  
  func run(f MyFunc, i int) {
      f.Run(i)
  }
  
  func main() {
      var newfunc func(int) //explicit declaration
      newfunc = func(i int) {
          fmt.Println(i)
      }
      run(newfunc, 10) //works just fine, even though types seem to differ
  }
  </code></pre>
  
  <p>Now, I'm not complaining because it saves me having to explicitly cast <code>newfunc</code> to type <code>MyFunc</code>, as I would have to do in the first example; it just seems inconsistent. I'm sure there is a good reason for it; can anyone enlighten me?</p>
  
  <p>The reason I ask is mainly because I would like to shorten some of my rather long function types in this way, but I want to make sure it's expected and acceptable to do this :)</p>