1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-12-05 21:56:14 +02:00

Add examples

This commit is contained in:
Asim Aslam
2020-12-26 15:17:20 +00:00
parent 273bab5dd7
commit a34c70de0e
320 changed files with 20803 additions and 0 deletions

27
examples/function/main.go Normal file
View File

@@ -0,0 +1,27 @@
package main
import (
"context"
proto "github.com/micro/examples/function/proto"
"github.com/micro/go-micro/v2"
)
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()
}