1
0
mirror of https://github.com/chai2010/advanced-go-programming-book.git synced 2025-05-24 04:22:22 +00:00
2018-12-16 12:40:54 +08:00

27 lines
431 B
Go

package main
import (
"context"
"fmt"
"log"
"google.golang.org/grpc"
hs "ch4.4-1/helloservice"
)
func main() {
conn, err := grpc.Dial("localhost:1234", grpc.WithInsecure())
if err != nil {
log.Fatal(err)
}
defer conn.Close()
client := hs.NewHelloServiceClient(conn)
reply, err := client.Hello(context.Background(), &hs.String{Value: "hello"})
if err != nil {
log.Fatal(err)
}
fmt.Println(reply.GetValue())
}