Skip to content

Latest commit

 

History

History
 
 

hertz_gorm_gen

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

hertz_gorm_gen

Introduce

A demo with Hertz and GORM/Gen

  • Use proto IDL to define HTTP interface
  • Use hz to generate code
  • Use Hertz binding and validate
  • Use GORM/Gen and MySQL

IDL

This demo use proto IDL to define HTTP interface. The specific user interface define in user.proto.

Code generation tool

This demo use hz to generate code. The use of hz refers to hz.

The hz commands used can be found in Makefile.

Binding and Validate

The use of binding and Validate refers to Binding and Validate.

GORM/Gen

GEN: Friendly & Safer GORM powered by Code Generation.

This demo use GORM/Gen to operate MySQL and refers to Gen.

Quick Start

  • 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

How to run

Run mysql docker

cd bizdemo/hertz_gorm_gen && docker-compose up

Run demo

cd bizdemo/hertz_gorm_gen
go build -o hertz_gorm_gen &&./hertz_gorm_gen