标签:local 为知笔记 ref http row 客户 nil 客户端 client
package main
import (
"context"
"fmt"
"google.golang.org/grpc"
"grpccli/services"
"log"
)
func main() {
conn, err := grpc.Dial("localhost:8081", grpc.WithInsecure())
if err != nil {
log.Fatal(err)
}
defer conn.Close()
prodClient := services.NewProdServiceClient(conn)//把在服务端生成的protobuf的go文件拷贝到services目录下
prodRes, err := prodClient.GetProdStock(context.Background(), &services.ProdRequest{ProdId: 12})
if err != nil {
log.Fatal(err)
}
fmt.Println(prodRes.ProdStock)
}
标签:local 为知笔记 ref http row 客户 nil 客户端 client
原文地址:https://www.cnblogs.com/hualou/p/12070517.html