Use exported Get methods in Go quick-start

Suggest users to use the exported Get methods instead of directly accessing the data.
This commit is contained in:
Michael Le 2019-08-22 03:00:20 -04:00 committed by GitHub
parent ab18a3d847
commit f028dbcfeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -162,7 +162,7 @@ Edit `greeter_server/main.go` and add the following function to it:
```go
func (s *server) SayHelloAgain(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
return &pb.HelloReply{Message: "Hello again " + in.Name}, nil
return &pb.HelloReply{Message: "Hello again " + in.GetName()}, nil
}
```
@ -175,7 +175,7 @@ r, err = c.SayHelloAgain(ctx, &pb.HelloRequest{Name: name})
if err != nil {
log.Fatalf("could not greet: %v", err)
}
log.Printf("Greeting: %s", r.Message)
log.Printf("Greeting: %s", r.GetMessage())
```
#### Run!
@ -206,4 +206,4 @@ Greeting: Hello again world
and [gRPC Concepts](/docs/guides/concepts/)
- Work through a more detailed tutorial in [gRPC Basics: Go](/docs/tutorials/basic/go/)
- Explore the gRPC Go core API in its [reference
documentation](https://godoc.org/google.golang.org/grpc)
documentation](https://godoc.org/google.golang.org/grpc)