mirror of
https://github.com/chai2010/advanced-go-programming-book.git
synced 2025-05-24 20:52:22 +00:00
27 lines
431 B
Go
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())
|
|
}
|