Let helloworld example listen to all hosts (#5089)

This commit changes the address that the helloworld greeter_server is
listening to from "localhost:<port>" to just ":<port>", thus enabling
the server to be used in setups where the request stem from another
host.

Signed-off-by: Thomas Hallgren <thomas@tada.se>
This commit is contained in:
Thomas Hallgren
2022-01-25 00:38:04 +01:00
committed by GitHub
parent 9cb4113808
commit 5b3768235a

View File

@ -47,7 +47,7 @@ func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloRe
func main() { func main() {
flag.Parse() flag.Parse()
lis, err := net.Listen("tcp", fmt.Sprintf("localhost:%d", *port)) lis, err := net.Listen("tcp", fmt.Sprintf(":%d", *port))
if err != nil { if err != nil {
log.Fatalf("failed to listen: %v", err) log.Fatalf("failed to listen: %v", err)
} }