Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eddycjy/go-gin-example
An example of gin
https://github.com/eddycjy/go-gin-example
api endless gin go golang gorm jwt swagger
Last synced: 3 days ago
JSON representation
An example of gin
- Host: GitHub
- URL: https://github.com/eddycjy/go-gin-example
- Owner: eddycjy
- License: mit
- Created: 2018-02-16T12:06:24.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-07-07T01:59:34.000Z (over 1 year ago)
- Last Synced: 2025-01-01T18:07:03.514Z (10 days ago)
- Topics: api, endless, gin, go, golang, gorm, jwt, swagger
- Language: Go
- Size: 22.5 MB
- Stars: 6,935
- Watchers: 139
- Forks: 1,601
- Open Issues: 51
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - eddycjy/go-gin-example
- my-awesome - eddycjy/go-gin-example - 07 star:6.9k fork:1.6k An example of gin (Go)
- awesome-github-star - go-gin-example
- awesome-golang-repositories - go-gin-example
README
# Go Gin Example [![rcard](https://goreportcard.com/badge/github.com/EDDYCJY/go-gin-example)](https://goreportcard.com/report/github.com/EDDYCJY/go-gin-example) [![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](https://godoc.org/github.com/EDDYCJY/go-gin-example) [![License](http://img.shields.io/badge/license-mit-blue.svg?style=flat-square)](https://raw.githubusercontent.com/EDDYCJY/go-gin-example/master/LICENSE)
An example of gin contains many useful features
[简体中文](https://github.com/EDDYCJY/go-gin-example/blob/master/README_ZH.md)
## Installation
```
$ go get github.com/EDDYCJY/go-gin-example
```## How to run
### Required
- Mysql
- Redis### Ready
Create a **blog database** and import [SQL](https://github.com/EDDYCJY/go-gin-example/blob/master/docs/sql/blog.sql)
### Conf
You should modify `conf/app.ini`
```
[database]
Type = mysql
User = root
Password =
Host = 127.0.0.1:3306
Name = blog
TablePrefix = blog_[redis]
Host = 127.0.0.1:6379
Password =
MaxIdle = 30
MaxActive = 30
IdleTimeout = 200
...
```### Run
```
$ cd $GOPATH/src/go-gin-example$ go run main.go
```Project information and existing API
```
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
- using env: export GIN_MODE=release
- using code: gin.SetMode(gin.ReleaseMode)[GIN-debug] GET /auth --> github.com/EDDYCJY/go-gin-example/routers/api.GetAuth (3 handlers)
[GIN-debug] GET /swagger/*any --> github.com/EDDYCJY/go-gin-example/vendor/github.com/swaggo/gin-swagger.WrapHandler.func1 (3 handlers)
[GIN-debug] GET /api/v1/tags --> github.com/EDDYCJY/go-gin-example/routers/api/v1.GetTags (4 handlers)
[GIN-debug] POST /api/v1/tags --> github.com/EDDYCJY/go-gin-example/routers/api/v1.AddTag (4 handlers)
[GIN-debug] PUT /api/v1/tags/:id --> github.com/EDDYCJY/go-gin-example/routers/api/v1.EditTag (4 handlers)
[GIN-debug] DELETE /api/v1/tags/:id --> github.com/EDDYCJY/go-gin-example/routers/api/v1.DeleteTag (4 handlers)
[GIN-debug] GET /api/v1/articles --> github.com/EDDYCJY/go-gin-example/routers/api/v1.GetArticles (4 handlers)
[GIN-debug] GET /api/v1/articles/:id --> github.com/EDDYCJY/go-gin-example/routers/api/v1.GetArticle (4 handlers)
[GIN-debug] POST /api/v1/articles --> github.com/EDDYCJY/go-gin-example/routers/api/v1.AddArticle (4 handlers)
[GIN-debug] PUT /api/v1/articles/:id --> github.com/EDDYCJY/go-gin-example/routers/api/v1.EditArticle (4 handlers)
[GIN-debug] DELETE /api/v1/articles/:id --> github.com/EDDYCJY/go-gin-example/routers/api/v1.DeleteArticle (4 handlers)Listening port is 8000
Actual pid is 4393
```
Swagger doc![image](https://i.imgur.com/bVRLTP4.jpg)
## Features
- RESTful API
- Gorm
- Swagger
- logging
- Jwt-go
- Gin
- Graceful restart or stop (fvbock/endless)
- App configurable
- Cron
- Redis