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?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?