Ginbro is a scaffold tool for Gin-Gorm-MySQL which you just need to input one command to create a mighty RESTful APIs App.
- this Repo's code has transfered to Felix/ginbro, please visitdejavuzhou/felix
- 代码已经转移到dejavuzhou/felix/ginbro,请移步至dejavuzhou/felix/ginbro
- fastest way to generate a RESTful APIs application with MySQL in Go
- support JWT Authorization Bearer Auth and JWT middleware
- support brute-force-login firewall
- build in swift golang-memory cache
- generate GORM model from MySQL database schema
- powered with Swagger document and SwaggerUI
- capable of serve VueJs app's static files
- configurable CORS middleware
- user friendly configuration
- golang GUI app
- fully build-in cron task support
- travis CI/CD
you can install it by go get
command:
go get github.com/dejavuzhou/ginbro
the Ginbro executable binary will locate in $GOPATH/bin check GOBIN is in your environment PATH
example
ginbro gen -u root -p Password -a "127.0.0.1:3306" -d databasename -o "github.com/user/awesome" -c utf8 --authTable=users --authPassword=password
$ ginbro gen -h
generate a RESTful APIs app with gin and gorm for gophers
Usage:
ginbro gen [flags]
Examples:
ginbro gen -u root -p password -a "127.0.0.1:38306" -d dbname -c utf8 --authTable=users --authPassword=pw_column -o=github.com/dejavuzhou/ginbro/out"
Flags:
-l, --appListen string app listen Address eg:mojotv.cn, using domain will support gin-TLS (default "127.0.0.1:5555")
--authPassword string password bycrpt column (default "password")
--authTable string the MySQL login table (default "users")
-h, --help help for gen
-o, --outPackage string output package relative to $GOPATH/src
Global Flags:
--config string config file (default is $HOME/ginbro.yaml)
-a, --mysqlAddr string MySQL host:port (default "127.0.0.1:3306")
-c, --mysqlCharset string MySQL charset (default "utf8")
-d, --mysqlDatabase string MySQL database name
-p, --mysqlPassword string MySQL password (default "password")
-u, --mysqlUser string MySQL user name (default "root")
the generated project directory ginbro DEMO-code-repository
2. ginbro bare
generate a bare project with one resource which you have to edit the config.toml
which is easy for you to customize
$ ginbro bare -h
create a bare project which its mysql flags are not necessary
Usage:
ginbro bare [flags]
Examples:
ginbro bare -o=github.com/dejavuzhou/ginbro/out5"
Flags:
-h, --help help for bare
-o, --outPackage string output package relative to $GOPATH/src
$ genbro model -h
generate GORM models of MySQL tables.
Usage:
ginbro model [flags]
Examples:
ginbro model -u root -p password -a 127.0.0.1:3306 -d venom -c utf8 -o=github.com/dejavuzhou/ginbro/out_model
Flags:
-h, --help help for model
-o, --outPackage string eg: models,the models will be created at $GOPATH/src/models
Global Flags:
--config string config file (default is $HOME/ginbro.yaml)
-a, --mysqlAddr string MySQL host:port (default "127.0.0.1:3306")
-c, --mysqlCharset string MySQL charset (default "utf8")
-d, --mysqlDatabase string MySQL database name
-p, --mysqlPassword string MySQL password (default "password")
-u, --mysqlUser string MySQL user name (default "root")
- my development environment
- Windows 10 pro 64
- go version go1.11.1 windows/amd64
- mysql version <= 5.7
go get github.com/gin-contrib/cors
go get github.com/gin-contrib/static
go get github.com/gin-gonic/autotls
go get github.com/gin-gonic/gin
go get github.com/sirupsen/logrus
go get github.com/spf13/viper
go get github.com/spf13/cobra
go get github.com/go-redis/redis
go get github.com/go-sql-driver/mysql
go get github.com/jinzhu/gorm
go get github.com/dgrijalva/jwt-go
mkdir -p $GOPATH/src/golang.org/x
cd $GOPATH/src/golang.org/x
git clone https://github.com/golang/crypto
git clone https://github.com/golang/text
retry the commandgo get github.com/dejavuzhou/ginbro
- resource table'schema which has no "ID","id","Id'" or "iD" will not generate model or route.
- the column which type is json value must be a string which is able to decode into a JSON, when resource is called POST or PATCH from the swaggerUI.