Coder Social home page Coder Social logo

alex-held / go-starter-kit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from qreasio/go-starter-kit

0.0 2.0 0.0 92 KB

Go Rest API starter kit / Golang API boilerplate base on Chi framework

Home Page: https://gostarterkit.com

License: MIT License

Makefile 3.68% Go 92.97% TSQL 2.25% Shell 1.10%

go-starter-kit's Introduction

Go Starter Kit

This project is opinionated Go starter kit / golang boilerplate that uses the golang standards project layout, using best and proven libraries and implements best practices for great foundation of Golang API project.

Background

When I want to start to build Go API project, i don't have a good solid base to start and usually I add the library and add another required thing one by one along the time, and then change again if I find another better library or another better way to do thing. So I tried to research architecture, library and software component/layer that I think better suits to be included for solid golang project.

Architecture

This project follows SOLID & Clean architecture

Features

  • Versioning
  • Pagination
  • Configuration
  • Logging
  • Error Handling
  • Validation
  • Health Check
  • Data Seed
  • DB Migration
  • Run & Manage via CLI Command
  • Makefile
  • Linter
  • Unit Test
  • Docker & Docker Compose
  • Integration Test sample

Todo:

  • Add more examples for service, repository and test
  • JWT base Authentication
  • Observability/Metrics
  • Kubernetes deployment
  • Use Cobra for CLI
  • Viper for better handling env and config

Website

Github: https://github.com/qreasio/go-starter-kit

Gostarterkit site: https://gostarterkit.com

Go Libraries

  • Go 1.14
  • Base web framework & Routing using github.com/go-chi/chi
  • Validation with github.com/go-playground/validator/
  • Database with github.com/jmoiron/sqlx
  • Logging with go.uber.org/zap
  • Migration with github.com/go-migrate/migration
  • YAML with gopkg.in/yaml.v2
  • Linter with github.com/golangci/golangci-lint
  • Go static analysis with staticcheck.io https://github.com/dominikh/go-tools
  • Mock generator using github.com/golang/mock

Get Started

Below are the steps if you want to run locally without docker

  1. Set required environment variable

    ENV=local

  2. Set configuration

    Change config/local.yaml configuration value properly and make sure can connect to blank MySQL database properly

  3. Run migration

    make migrate

  4. Add seed data

    make seed

  5. Run app

    make run

  6. Open the browser

    Visit the url

    http://localhost:8080/v1/users

Run Test

go test -v ./internal/user/...

Get Started Using Docker Compose

Below are the steps if you want to run locally with docker & docker compose

  1. Build docker image

    Generate the docker imgae by this command:

    docker build --rm -t starterkitapi -f dockerfile.api .

  2. Run with docker compose

    Copy the sample.env to .env and adjust it then run the docker compose with this command:

    docker-compose up

  3. Open the browser

    Visit the url

    http://localhost:8080/v1/users

  4. Quit & Cleanup

    Click Ctrl+C to quit in console then run these commands below to clean up all things:

    docker-compose rm -v

Inspiration

Golang Project Layout https://github.com/golang-standards/project-layout

ArdanLabs Service https://github.com/ardanlabs/service

GORSK - GO(lang) Restful Starter Kit https://github.com/ribice/gorsk/

Go REST API starter kit https://github.com/qiangxue/go-rest-api

Author

Isak Rickyanto

Twitter: @isakric

Personal site: https://rickyanto.com

go-starter-kit's People

Contributors

isakfm avatar qreasio avatar

Watchers

James Cloos avatar  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.