I am studying web development in Golang (Beginner) I came across some code I played around with and I\'m not too sure why it works, I looked through the library source code
The relevant type in net/http is
type Handler interface {
ServeHTTP(ResponseWriter, *Request)
}
an interface type. Any concrete type implementing this interface can be used to serve HTTP request. Your bar is of type foo and foo implements the Handler interface. If the builtin HTTP server has to handle a request it will call the ServeHTTP method of your bar.