Initialize embedded struct in Go

后端 未结 3 915
情话喂你
情话喂你 2021-02-03 20:16

I have the following struct which contains a net/http.Request:

type MyRequest struct {
    http.Request
    PathParams map[string]strin         


        
3条回答
  •  忘了有多久
    2021-02-03 20:48

    As Jeremy shows above, the "name" of an anonymous field is the same as the type of the field. So if the value of x were a struct containing an anonymous int, then x.int would refer to that field.

提交回复
热议问题