2020-12-26 17:17:20 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
|
2021-10-13 14:31:23 +02:00
|
|
|
"github.com/asim/go-micro/examples/v4/filter/version"
|
|
|
|
proto "github.com/asim/go-micro/examples/v4/service/proto"
|
2021-10-12 13:55:53 +02:00
|
|
|
"go-micro.dev/v4"
|
2020-12-26 17:17:20 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
service := micro.NewService()
|
|
|
|
service.Init()
|
|
|
|
|
|
|
|
greeter := proto.NewGreeterService("greeter", service.Client())
|
|
|
|
|
|
|
|
rsp, err := greeter.Hello(
|
|
|
|
// provide a context
|
|
|
|
context.TODO(),
|
|
|
|
// provide the request
|
|
|
|
&proto.Request{Name: "John"},
|
|
|
|
// set the filter
|
|
|
|
version.Filter("latest"),
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println(rsp.Greeting)
|
|
|
|
}
|