Skip to content

Instantly share code, notes, and snippets.

@KamilLelonek
Created March 10, 2019 13:25
Show Gist options
  • Save KamilLelonek/d0709a86e0d6e18ec3f09d0d8b211b06 to your computer and use it in GitHub Desktop.
Save KamilLelonek/d0709a86e0d6e18ec3f09d0d8b211b06 to your computer and use it in GitHub Desktop.
const address = "localhost:50051"
func main() {
conn, err := grpc.Dial(address, grpc.WithInsecure())
if err != nil {
log.Fatalf("did not connect: %v", err)
}
defer conn.Close()
c := pb.NewGravatarServiceClient(conn)
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
r, err := c.Generate(ctx, &pb.GravatarRequest{Email: "name", Size: 10})
if err != nil {
log.Fatalf("could not greet: %v", err)
}
log.Printf("Greeting: %s", r.Url)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment