|
|
@ -49,19 +49,18 @@ const ( |
|
|
|
|
|
|
|
|
|
|
|
func main() { |
|
|
|
func main() { |
|
|
|
// Set up a connection to the server.
|
|
|
|
// Set up a connection to the server.
|
|
|
|
var opts []grpc.DialOption |
|
|
|
conn, err := grpc.Dial(address) |
|
|
|
conn, err := grpc.Dial(address, opts...) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Fatalf("did not connect: %v", err) |
|
|
|
log.Fatalf("did not connect: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
|
defer conn.Close() |
|
|
|
defer conn.Close() |
|
|
|
|
|
|
|
c := pb.NewGreeterClient(conn) |
|
|
|
|
|
|
|
|
|
|
|
// Contact the server and print out its response.
|
|
|
|
// Contact the server and print out its response.
|
|
|
|
name := defaultName |
|
|
|
name := defaultName |
|
|
|
if len(os.Args) > 1 { |
|
|
|
if len(os.Args) > 1 { |
|
|
|
name = os.Args[1] |
|
|
|
name = os.Args[1] |
|
|
|
} |
|
|
|
} |
|
|
|
c := pb.NewGreeterClient(conn) |
|
|
|
|
|
|
|
r, err := c.SayHello(context.Background(), &pb.HelloRequest{Name: name}) |
|
|
|
r, err := c.SayHello(context.Background(), &pb.HelloRequest{Name: name}) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Fatalf("could not greet: %v", err) |
|
|
|
log.Fatalf("could not greet: %v", err) |
|
|
|