Usage
Tool Usage
Output:
kratos version v2.0.0
To create a new project:
helloworld
|____api
| |____helloworld
| | |____v1
| | | |____helloworld_grpc.pb.go
| | | |____helloworld.proto
| | | |____helloworld.pb.go
| | | |____helloworld_http.pb.go
| | |____errors
| | | |____helloworld_errors.pb.go
| | | |____helloworld.proto
| | | |____helloworld.pb.go
|____cmd
| |____helloworld
|____internal
| |____biz
| | |____README.md
| |____service
| | |____README.md
| |____data
| | |____README.md
|____README.md
|____Makefile
|____LICENSE
|____go.mod
|____go.sum
Adding Proto files
kratos proto add api/helloworld/demo.proto
Output:
api/helloworld/demo.proto
kratos proto client api/helloworld/demo.proto
api/helloworld/demo.pb.go
api/helloworld/demo_grpc.pb.go
api/helloworld/demo_http.pb.go
Generate Service Codes
kratos can generate the bootstrap codes from the proto file.
Output: internal/service/demo.go
package service
import (
"context"
)
type DemoService struct {
}
func NewDemoService() pb.DemoServer {
return &DemoService{}
}
func (s *DemoService) CreateDemo(ctx context.Context, req *pb.CreateDemoRequest) (*pb.CreateDemoReply, error) {
return &pb.CreateDemoReply{}, nil
}
func (s *DemoService) UpdateDemo(ctx context.Context, req *pb.UpdateDemoRequest) (*pb.UpdateDemoReply, error) {
return &pb.UpdateDemoReply{}, nil
}
func (s *DemoService) DeleteDemo(ctx context.Context, req *pb.DeleteDemoRequest) (*pb.DeleteDemoReply, error) {
return &pb.DeleteDemoReply{}, nil
}
func (s *DemoService) GetDemo(ctx context.Context, req *pb.GetDemoRequest) (*pb.GetDemoReply, error) {
return &pb.GetDemoReply{}, nil
}
func (s *DemoService) ListDemo(ctx context.Context, req *pb.ListDemoRequest) (*pb.ListDemoReply, error) {
}