Coder Social home page Coder Social logo

go-boilerplate's Introduction

GoRestBoilerPlate

A simple REST API boilerplate for Go

Why use this boilerplate

This project has the following features:

  • Fast routing with Gin
  • JWT middleware Included
  • User authentication routes added
  • GORM, Go ORM added with support for multiple databases
  • Secure route authorization using user roles
  • Simple project structure

Getting Started

SQL

To create a new SQL migration use this command

migrate create -ext sql -dir ./infrastructure/modules/gorm/migrations -seq NAME_FOR_MIGRATION

Manually run migrations

migrate -path infrastructure/modules/gorm/migrations -database "postgresql://dbuser:dbpass@localhost:5432/boilerplate?sslmode=disable" -verbose up

Rollback version

migrate -path infrastructure/modules/gorm/migrations -database "postgresql://dbuser:dbpass@localhost:5432/boilerplate?sslmode=disable" force 15

NoSQL

To create a new NoSQL migration use this command

go run infrastructure/modules/mongo/utils/migrations/manager.go new NAME_FOR_MIGRATION

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

go get ...
go run main.go

Prerequisites

Go environment must be setup.

For protos you should install protobuf on your system and execute the following command to install the plugin for golang protos generator.

go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]

To build the protos use the command below

protoc infrastructure/modules/grpc/protos/raw/*.proto --go_out=infrastructure/modules/grpc/protos/build --go_opt=paths=source_relative --go-grpc_out=infrastructure/modules/grpc/protos/build --go-grpc_opt=paths=source_relative --proto_path=infrastructure/modules/grpc/protos/raw

Built With

  • Gin - HTTP web framework
  • GORM - ORM library for Golang

go-boilerplate's People

Contributors

vieirinhaabr avatar ninjawerk avatar

Stargazers

Hadj H. avatar

Watchers

 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.