Skip to content

Instantly share code, notes, and snippets.

@mrnim94
Last active March 5, 2022 16:58
Show Gist options
  • Save mrnim94/9871063cc7118e0b4b4e98fcc1c6fcb9 to your computer and use it in GitHub Desktop.
Save mrnim94/9871063cc7118e0b4b4e98fcc1c6fcb9 to your computer and use it in GitHub Desktop.
client grpc With Insecure
func main() {
serverGrpcPort := os.Getenv("HOST_SERVER_NAME")+":"+os.Getenv("PORT_SERVER_NAME")
//client connect đến grpc server và ko bảo mật ssl
cc, err := grpc.Dial(serverGrpcPort, grpc.WithInsecure())
if err != nil {
log.Fatalf("error while create listen %v", err)
}
//khi sài xong chúng ta cần đóng connection lại
defer cc.Close()
//tạo client
client := calculatorpb.NewCalculatorServiceClient(cc)
for {
callSum(client)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment