Mangokit
Mangokit is a Go tool that helps you generate web projects based on a predefined project structure. It utilizes the Gin framework, Proto files for defining HTTP handlers and errors, and Wire for dependency injection.
Features
- Generate a web project with a predefined project structure.
- Utilize the Gin framework for building robust and performant web applications.
- Define HTTP handlers and errors using Proto files for easy API contract management.
- Implement dependency injection using Wire for cleaner and more modular code.
Install
git clone github.com/mangohow/mangokit
cd mangokit && make install
other tools:
# install proto-gen-gogo
git clone https://github.com/mangohow/protobuf.git
cd protobuf && make install
# install wire
go install github.com/google/wire/cmd/wire@latest
# install openapi
go install github.com/google/gnostic/cmd/protoc-gen-openapi@latest
# make sure you have protoc
Getting Started
To get started with Mangokit, follow these steps:
- Create a new web project:
mangokit create {projectFileName} {goModName}
.
cd {projectFileName} && go mod tidy
- Generate go files from proto files:
mangokit generate proto {protoDir}
- Generate openapi from proto files:
mangokit generate openapi {protoDir}
.
- Generate wire:
mangokit generate wire
.
- Add a proto api:
mangokit add api {path} {protoName}
.
- Add a proto error:
mangokit add error {path} {protoName}
.
Example
mangokit create helloworld github.com/xxx/helloworld
cd helloworld && go mod tidy
go run cmd/server/main.go cmd/server/wire_gen.go
Usage
Mangokit provides the following commands:
mangokit create
: Generate a new web project based on the predefined structure.
mangokit generate
: Generate go files or openapi from proto files and wire.
mangokit add
: Add proto files, makefile and Dockerfile.