Git Product home page Git Product logo

gen's Introduction

Auto create golang api project (gin+gorm+swagger), quickly build restful api and document.

gen-demo-gif

Example:

gen new blog-project

gen add api --model article --fields title:string,content:string,userId:int

gen add api -m user -f name:string,email:string,password:string

Detail:

step-0 install gen

go get -u github.com/cyjme/gen

go get -u github.com/swaggo/swag/cmd/swag

step-1 create project

gen new blog-project

step-2 edit config.yml

cd blog-project

vim config/config.yml

create database

step-3 install dependency, recommend use go mod

go mod tidy

step-4 add api

gen add api --model article --fields title:string,content:string,userId:int

step-5 run

go run main.go

Api document: your_url:port/swagger/index.html

Api: your_url:port/articles [post,get]

Api: your_url:port/articles/{id} [get,put,patch,delete]

more

get articles api, can use these params default:

your_url:port/articles?page=1&pageSize=10&query=title:like:%search_word%,user_id:=:1&order=created_at:desc,userId:asc

query param is an array split by , , the element is {field}:{=|>|<|like}:{value}

order param is an array split by , , the element is {field}:{asc|desc}

gen's People

Contributors

cyjme avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.