package main
import "fmt"
type Response struct {
Code int
Message string
}
func main() {
r, err := Do()
if err != nil {
return
}
fmt.Println(r)
}
func Do() (res *Response, err error) {
// res = &Response{}
res.Code = 200
res.Message = "ok"
return
}
没加 res = &Response{} 会空指针异常