Please first have a look at the code below.
package main
import "fmt"
type InterfaceFunc func(interface{})
type StringFunc func(string)
func stringFunc(s string) {
fmt.Printf("%v", s)
}
func interfaceFunc(i interface{}) {
fmt.Printf("%v", i)
}
func main() {
var i = interfaceFunc
var s = stringFunc
i = s // I would like someone to explain why this can't be done exactly.
}
Run at https://play.golang.org/p/16cE4O3eb95
Why an InterfaceFunc
can't hold a StringFunc
while an interface{}
can hold a string
.