I see this code: type HandlerFunc func(ResponseWriter, *Request)
func (f HandlerFunc) ServeHTTP(w ResponseWriter, r *Request) { f(w, r) } i imitate this but my code can not compile: [john@localhost 01]$ cat inspiration_by_golang_http.go package main import "fmt" type Handler interface { Call(x, y int) } func Add(x, y int) { fmt.Println(x+y) } type HandlerFunc func(x, y int) func (f HandlerFunc) Call(x, y int) { f(x, y) } func main() { demo := HandlerFunc{} var i Handler i = demo i.Call(1, 2) } [john@localhost 01]$ go run inspiration_by_golang_http.go # command-line-arguments ./inspiration_by_golang_http.go:17: invalid type for composite literal: HandlerFunc Why? I want to know. Thinks! My computer arch is amd64. OS is linux. Distribution is fc24. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.