我遵循编写Go服务器的指南here。声明Serve HTTP服务器的方法
我不明白以下块:
func (*myHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// ^^^^^ What does this do?
它没有看起来像一个返回类型。在Go中,我的理解是返回类型遵循函数的参数。像这样的函数返回一个整数:
func hello(s String) int {}
那么,是什么在ServeHTTP声明(*myHandler)
吗?
ServeHTTP是一个* myHandler类型的方法。请参阅https://tour.golang.org/methods/1 –