gin protobuf客户端测试
gin protobuf客户端测试
// clientGIN project main.go package main import ( "clientGIN/model" "fmt" "io/ioutil" "net/http" "google.golang.org/protobuf/proto" ) func main() { resp, err := http.Post("http://localhost:1234/protobuf/units/select", "application/x-protobuffer", nil) if err != nil { fmt.Println(err) } else { defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err) } else { var dws model.TunitArray proto.Unmarshal(body, &dws) for _, dw := range dws.Tunits { fmt.Println(dw.Unitid, dw.Unitname) } } } }
本文来自博客园,作者:{咏南中间件},转载请注明原文链接:https://www.cnblogs.com/hnxxcxg/p/16536782.html