我知道我可以写出下面这样的代码,但我不知道它是如何工作的:
type MyTransport struct {
http.Transport
}
func (myT *MyTransport) RoundTrip(r *http.Request) (*http.Response, error) {
return myT.Transport.RoundTrip(r)
}
http.Transport
只是一个结构体,它没有名称。那么myT.Transport
是如何工作的呢?为什么在MyTransport
中不需要给传输命名,例如像这样声明ht http.Transport
?