mirror of
https://github.com/go-micro/go-micro.git
synced 2025-02-04 18:21:53 +02:00
32 lines
525 B
Go
32 lines
525 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
hello "github.com/asim/go-micro/examples/v4/greeter/srv/proto/hello"
|
|
"go-micro.dev/v4"
|
|
)
|
|
|
|
func main() {
|
|
// create a new service
|
|
service := micro.NewService()
|
|
|
|
// parse command line flags
|
|
service.Init()
|
|
|
|
// Use the generated client stub
|
|
cl := hello.NewSayService("go.micro.srv.greeter", service.Client())
|
|
|
|
// Make request
|
|
rsp, err := cl.Hello(context.Background(), &hello.Request{
|
|
Name: "John",
|
|
})
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
|
|
fmt.Println(rsp.Msg)
|
|
}
|