Init the simplest client
authorJulien Andrieux <julien@pantomath.io>
Wed, 4 Oct 2017 21:55:47 +0000 (23:55 +0200)
committerJulien Andrieux <julien@pantomath.io>
Thu, 5 Oct 2017 10:54:42 +0000 (12:54 +0200)
client/main.go [new file with mode: 0644]

diff --git a/client/main.go b/client/main.go
new file mode 100644 (file)
index 0000000..1151776
--- /dev/null
@@ -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)
+}