Skip to content

CaiJinKen/gostruct-ast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gostruct

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) and gorm tag
  • print the struct(default)
  • sort struct fields

Help:

gostruct-ast --help

or

gostruct-ast -h