• This repository has been archived on 26/Jul/2019
  • Stars
    star
    115
  • Rank 305,916 (Top 7 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 6 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Converting a MySQL database'schema to a RESTful golang APIs app in the fastest way

Converting a MySQL database'schema to a RESTful golang APIs app in the fastest way

Build Status GoDoc Go Report Card stability-stable codebeat badge codecov

Ginbro is a scaffold tool for Gin-Gorm-MySQL which you just need to input one command to create a mighty RESTful APIs App.

Warning

- this Repo's code has transfered to Felix/ginbro, please visitdejavuzhou/felix

- 代码已经转移到dejavuzhou/felix/ginbro,请移步至dejavuzhou/felix/ginbro

Demo and Translated Document

Feature

Ginbro Installation

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

Usage

1. ginbro gen generate a new Gin+Gorm+MySQL RESTful APIs Application with JWT middleware and auth

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

3. ginbro model generate GORM models of tables in a MySQL database

$ 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")

GUI

Boilerplate Project

environment

  • my development environment
    • Windows 10 pro 64
    • go version go1.11.1 windows/amd64
    • mysql version <= 5.7

go packages

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

How to fix go get golang.org/x/crypto/bcrypt and go get golang.org/x/crypto/text error

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

Info

  • 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.

Thanks

Please feedback your issue with database schema file

More Repositories

1

base64Captcha

captcha of base64 image string
Go
2,102
star
2

felix

A Friendly SSH Jumper Bastion Fortress Server
Go
841
star
3

rdpgo

Go进阶53:从零Go实现Websocket-H5-RDP/VNC远程桌面客户端
Go
233
star
4

sshfortress

A pure and slim Golang SSH-Jumper-bastion-web app. One binary rules them all
Go
159
star
5

chromegin

chromedp-golang 浏览器截图docker 微服务教程
Go
41
star
6

flash

HTTP断点续传多线程下载原理
Go
16
star
7

screen_shot

go+phantomjs网页图片截取微服务
Go
14
star
8

www.mojotv.cn

beego website
HTML
10
star
9

felixfe

Vue
10
star
10

sseread

A tidy library seamlessly reads Server-Sent Events (SSE) from the response body of Go's standard HTTP package.
Go
10
star
11

springboot2app

Springboot2 JPA JWT RESTful APIs boilerplate
Java
9
star
12

recommend-go

用户偏好推荐系统
Go
7
star
13

sshimdemo

Golang开发扩展SSH的使用领域和功能
Go
5
star
14

wordCloudDocker

wordcloud云词docker教程
Python
4
star
15

eslogrushook

博客文章源码: Go进阶45:Golang-logrus简单的日志收集系统(替代ELKB)
Go
4
star
16

blogcode

Go
3
star
17

alg-tea

Go进阶50:简单高效加密算法TEA
Go
2
star
18

httpproxyapp

HTTP-Reverse-Proxy反向代理nginx硬件指纹校验
Go
1
star
19

dueros-bang-game

生活大爆炸-谢尔顿-剪刀石头布-百度智能音箱
PHP
1
star
20

mojocn

1
star
21

util

Go
1
star
22

gptchat

A fullstack chat app, powered by openai GPT, helps you make money - 💰💰💰
TypeScript
1
star
23

wasmdict

the English-Chinese Oxford Dictionary Library, a comprehensive and efficient tool designed to provide seamless dictionary lookup capabilities for both Go and WASM environments.
Go
1
star
24

hillClimbRacing

Hill Climb Racing with different characters. Code by Code Bullet from his website. I just changed colors and assets, and made it touchscreen compatible.
JavaScript
1
star