1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-01-23 17:53:05 +02:00

31 lines
502 B
Go
Raw Normal View History

2020-12-26 15:17:20 +00:00
package main
import (
"context"
"log"
pb "github.com/micro/examples/helloworld/proto"
"github.com/micro/go-micro/v2"
)
type Greeter struct{}
func (g *Greeter) Hello(ctx context.Context, req *pb.Request, rsp *pb.Response) error {
rsp.Greeting = "Hello " + req.Name
return nil
}
func main() {
service := micro.NewService(
micro.Name("helloworld"),
)
service.Init()
pb.RegisterGreeterHandler(service.Server(), new(Greeter))
if err := service.Run(); err != nil {
log.Fatal(err)
}
}