package main
import (
"context"
"fmt"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"grpccli/services"
"log"
)
func main() {
creds, err := credentials.NewClientTLSFromFile("keys/server.crt", "jtthink.com")//证书中的common name写的什么这里就些什么
conn, err := grpc.Dial(":8081", grpc.WithTransportCredentials(creds))
if err != nil {
log.Fatal(err)
}
defer conn.Close()
prodClient := services.NewProdServiceClient(conn)
prodRes, err := prodClient.GetProdStock(context.Background(), &services.ProdRequest{ProdId: 12})
if err != nil {
log.Fatal(err)
}
fmt.Println(prodRes.ProdStock)
}