gin-rest-api-sample

Golang REST API sample with MariaDB integration using Gin and GORM

  • 所有者: velopert/gin-rest-api-sample
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

gin-rest-api-sample

Golang REST API sample with MariaDB integration using Gin and GORM. (This project IS NOT a starter kit, it is just an example project.)

This project is a sample project that contains following features:

Project Setup

$ dep ensure
$ go get github.com/jinzhu/gorm
$ go get github.com/codegangsta/gin

GORM should be installed via go get since installation via dep is imperfect (it does not download dialects directory).

codegangsta/gin is an optional package to install if you want to make usage of live reloading feature of server (just like nodemon in Node.js environment).

MariaDB Configuration

This project uses MariaDB to store data. Install MariaDB and create a sample database and a user account.

Install MariaDB

Create Database / Account

CREATE DATABASE sample;
GRANT ALL PRIVILEGES ON sample.* to sample@'%' IDENTIFIED BY 'samplepass';
GRANT ALL PRIVILEGES ON sample.* to sample@'localhost' IDENTIFIED BY 'samplepass';

Configure Environment Variables

Open .env file and edit the values if you need to. This project uses godotenv to read and use .env file.

Database config string is formatted in go-sql-driver format.

Start Project

$ go run main.go

To explicitly compile the code before you run the server:

$ go build main.go
$ ./main

To use live-reloading in development environment,

$ ./scripts/start-dev

主要指标

概览
名称与所有者velopert/gin-rest-api-sample
主编程语言Go
编程语言Go (语言数: 2)
平台
许可证MIT License
所有者活动
创建于2018-07-31 10:09:20
推送于2020-01-26 19:00:36
最后一次提交2018-07-31 19:19:43
发布数0
用户参与
星数187
关注者数8
派生数43
提交数10
已启用问题?
问题数1
打开的问题数1
拉请求数0
打开的拉请求数2
关闭的拉请求数0
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?