mirror of
https://github.com/go-micro/go-micro.git
synced 2025-03-23 20:32:32 +02:00
32 lines
527 B
Go
32 lines
527 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"fmt"
|
||
|
|
||
|
hello "github.com/micro/examples/greeter/srv/proto/hello"
|
||
|
"github.com/micro/go-micro/v2"
|
||
|
)
|
||
|
|
||
|
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)
|
||
|
}
|