为什么invalid memory address or nil pointer dereference跑步时会打招呼?
type Response struct {
Message string `json:"message"`
}
type ResponseList struct {
Items []*Response `json:"items"`
}
func (gs *GreetingService) List(r *http.Request, req *Request, resp *ResponseList) error {
greets := make([]*Response,2,2)
greets[0].Message="hello"
greets[1].Message="goodbye"
resp.Items = greets
return nil
}
宝慕林4294392
沧海一幻觉
相关分类