github.com/micro/go-micro/examples@v0.0.0-20210105173217-bf4ab679e18b/function/main.go (about) 1 package main 2 3 import ( 4 "context" 5 6 proto "github.com/micro/go-micro/examples/function/proto" 7 "github.com/micro/go-micro/v2" 8 ) 9 10 type Greeter struct{} 11 12 func (g *Greeter) Hello(ctx context.Context, req *proto.HelloRequest, rsp *proto.HelloResponse) error { 13 rsp.Greeting = "Hello " + req.Name 14 return nil 15 } 16 17 func main() { 18 fnc := micro.NewFunction( 19 micro.Name("greeter"), 20 ) 21 22 fnc.Init() 23 24 fnc.Handle(new(Greeter)) 25 26 fnc.Run() 27 }