A powerful toolkit for building stable and maintainable Golang server-side projects.
Cato's current capabilities are provided through a series of proto-gen-* plugins.
proto-gen-cato requires your .proto file content to adhere to the Protocol Buffers Official Style Guide. Otherwise, the generated struct field names may be difficult to understand.
This plugin provides various capabilities by using custom options from the proto directory within different scopes.
For specific usage examples, please refer to the proto files in cato-example-bms (Simple Book Management System).
The responsibilities of the files in the proto directory are divided as follows:
extension.proto: Main entry point for plugin options.db.proto: Options related to relational databases.defines.proto: Options for controlling file generation.http.proto: Options for generating HTTP service-related code.struct.proto: Options for general struct-related generation.
go install -v github.com/ncuhome/cato/cmd/protoc-gen-cato@latestFirst, you need to reference the *.proto files from the proto directory. Download the proto files locally.
# Note: Replace /cato/proto/path with your local path to the `cato/proto` directory.
protoc -I=your/project/proto/path -I=/cato/proto/path --cato_out=../ --cato_opt=ext_out_dir=../,swagger_path=swagger.json,api_host=localhost path/to/your/file.protoext_out_dir: The base directory for Cato's generated files, which should be consistent withcato_out.swagger_path: If you need to generate OpenAPI documentation, specify the path for theswagger.jsonfile.api_host: Specifies the host attribute in theswagger.jsonfile.
Core Features:
- Using
db.protooptions to generate:- Database-related
Tablemodels. - Database
Repomethods:Find,Delete,Insert,Update. - Implementation of relational database
Rdbmethods.
- Database-related
- Using
http.protooptions to generate:HTTP APIinterface methods.HTTP paramsdefinitions and parameter binding.OpenAPI 2.0interface documentation.
- Using
struct.protooptions to generate:- Structs with
tags, typically used for generatingBO(Business Objects). Mappermethods for converting between different structs.
- Structs with
Cato is committed to the long-term maintenance of stability and clarity in your Golang server-side projects. The name Cato is inspired by the game 《CATO: Butterered Cat》, whose core concept is "a cat always lands on its feet."
For Golang server-side projects, using Cato helps ensure your project always lands smoothly—maintaining stability and controllability while enabling the codebase to possess the flexibility and fluidity of a cat.
We have many, many features, plans, and improvements yet to complete.
- Establish common packages to abstract foundational
interfaces. - Support
DDLstatement generation andDB Migrate. - Support
enumtype generation. - Optimize the generation method for
RdbandRepo. - Optimize the global passing of the
generator context. - ...