From: Julien Andrieux Date: Wed, 4 Oct 2017 21:55:47 +0000 (+0200) Subject: Init the simplest client X-Git-Url: https://git.halfball.org/?a=commitdiff_plain;h=55274260b3d665a2b274a0a9ed3045a7ab9f0820;p=demo-grpc.git Init the simplest client --- diff --git a/client/main.go b/client/main.go new file mode 100644 index 0000000..1151776 --- /dev/null +++ b/client/main.go @@ -0,0 +1,27 @@ +package main + +import ( + "log" + + "gitlab.com/pantomath-io/demo-grpc/api" + "golang.org/x/net/context" + "google.golang.org/grpc" +) + +func main() { + var conn *grpc.ClientConn + + conn, err := grpc.Dial(":7777", grpc.WithInsecure()) + if err != nil { + log.Fatalf("did not connect: %s", err) + } + defer conn.Close() + + c := api.NewPingClient(conn) + + response, err := c.SayHello(context.Background(), &api.PingMessage{Greeting: "foo"}) + if err != nil { + log.Fatalf("Error when calling SayHello: %s", err) + } + log.Printf("Response from server: %s", response.Greeting) +}