29 lines
644 B
Go
29 lines
644 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"fmt"
|
||
|
|
||
|
"gitlab.com/go-course-project/go17/skills/grpc/service"
|
||
|
"google.golang.org/grpc"
|
||
|
"google.golang.org/grpc/credentials/insecure"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
// Deprecated: use WithTransportCredentials and insecure.NewCredentials()
|
||
|
// instead. Will be supported throughout 1.x.
|
||
|
conn, err := grpc.NewClient("localhost:1234", grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
|
||
|
client := service.NewHelloServiceClient(conn)
|
||
|
resp, err := client.Hello(context.Background(), &service.HelloRequest{
|
||
|
MyName: "bob",
|
||
|
})
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
fmt.Println(resp)
|
||
|
}
|