1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-01-05 10:20:53 +02:00
go-micro/examples/function/main.go
2021-01-20 21:28:48 +00:00

28 lines
431 B
Go

package main
import (
"context"
proto "github.com/asim/go-micro/examples/v3/function/proto"
"github.com/asim/go-micro/v3"
)
type Greeter struct{}
func (g *Greeter) Hello(ctx context.Context, req *proto.HelloRequest, rsp *proto.HelloResponse) error {
rsp.Greeting = "Hello " + req.Name
return nil
}
func main() {
fnc := micro.NewFunction(
micro.Name("greeter"),
)
fnc.Init()
fnc.Handle(new(Greeter))
fnc.Run()
}