This is an open source tool convert mysql table structure to golang`s struct and written by pure golang.
Same as gostruct, but go/ast implementation
Install:
go get github.com/CaiJinKen/gostruct-ast
Usage:
- get struct from sql file
gostruct-ast -i users.sql -o users.go
- get struct from db connection
gostruct-ast -d `user:password@tcp(host:port)/db_name` -t users -o ./models/users.go
This tool also can:
- generate
json
tag(default) andgorm
tag
- print the struct(default)
- sort struct fields
Help:
gostruct-ast --help
or
gostruct-ast -h