entity-helper 中文
Useful go tool to generate struct according to database schema
go get -u github.com/nautilis/entity-helper
- fill database configuration on ~/.entity-hepler/conf.toml
DbAddress = "username:password@tcp(127.0.0.1:3306)/yourdb?charset=utf8mb4"
Db = "yourdb"
- declare the empty entity struct and comment go:generate with target struct name and table name .
//go:generate entity-helper -target User -table user_table_name
type User struct {
}
- execute
go generate
under package. - must delete the existed fields of the struct if you need to regenerate it.