fptda2

command module
v0.0.0-...-1b941cd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2021 License: MIT Imports: 6 Imported by: 0

README

gin-rest-api

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

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
api
lib

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL