A demo with Hertz
and GORM/Gen
- Use
proto
IDL to defineHTTP
interface - Use
hz
to generate code - Use
Hertz
binding and validate - Use
GORM/Gen
andMySQL
This demo use proto
IDL to define HTTP
interface. The specific user interface define in user.proto.
This demo use hz
to generate code. The use of hz
refers
to hz.
The hz
commands used can be found in Makefile.
The use of binding and Validate refers to Binding and Validate.
GEN: Friendly & Safer GORM powered by Code Generation.
This demo use GORM/Gen
to operate MySQL
and refers to Gen.
- Update the Database DSN to your own in Database init file.
- Refer to the code comments, write the configuration in Generate file.
- Using the following command for code generation, you can generate structs from databases or basic type-safe DAO API for struct.
cd bizdemo/hertz_gorm_gen/cmd
go run generate.go
- For more Gen usage, please refer to Gen Guides.
cd bizdemo/hertz_gorm_gen && docker-compose up
cd bizdemo/hertz_gorm_gen
go build -o hertz_gorm_gen &&./hertz_gorm_gen