爲什麼在運行時問候會給我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
}