Golang Service Template

Golang Service Template

Golang back-end service template. Using this template, you can get started with back-end projects quickly.

Web Framework ORM Database Driver Configuration Manager Log Manager API Documentation
labstack/echo/v4 gorm.io/gorm gorm.io/driver/mysql spf13/viper sirupsen/logrus swaggo/echo-swagger

Configuration

  1. Create database and user in MySQL, and grant privileges to user.
CREATE DATABASE buz;
CREATE USER 'foo'@'localhost' IDENTIFIED BY 'bar';
GRANT ALL PRIVILEGES ON buz.* TO 'foo'@'localhost';
  1. Create a file named conf.yaml in the project's root directory.
sql:
  username: foo
  password: bar
  db_name: buz
  1. To generate API doc, you need to execute the following commands:
go install github.com/swaggo/swag/cmd/swag@latest  # download swag, a doc generator
swag init  # docs will be written into `docs/` directory
  1. Compile and run this project. You will find API doc in http://localhost:1323/api/doc/index.html on default.
  2. Change the go module name of this project to whatever you like.

Usage

  1. To create tables, add structs in model/. model/foo.go is an example of such struct. Then, add the struct to DB.AutoMigrate in model/init.go.
  2. Add business logics in controller/, then add router in controller/routers.go.
  3. Write API doc alongside with the controller function. controller/foo.go is an example.
Owner
Ralph
Stare into the void | @QSCTech | @ZJUSCT | @milkice233
Ralph
Similar Resources

Template for Golang rest API using Fiber

Rest API Setup DB sudo -S docker-compose -f db.yml up -d Build container sudo -S docker build -t rest-api-image . Run container from image sudo -S doc

Dec 5, 2021

Clean Architecture template for Golang services

Clean Architecture template for Golang services

Go Clean template Clean Architecture template for Golang services Overview The purpose of the template is to show: how to organize a project and preve

Jul 11, 2022

Clean Architecture template for Golang services

Go Clean template Clean Architecture template for Golang services Overview The purpose of the template is to show: how to organize a project and preve

Nov 30, 2021

A Go Template Library. A bunch of utils and collections that are not part of the Golang standard library.

gotl A Go Template Library. A bunch of utils and collections that are not part of the Golang standard library. Prerequisites This library is using ext

Dec 15, 2021

Competitive Programming Template for Golang

Go Competitive Programming Template How to use this repo? Check the commit histo

Dec 19, 2021

Template user CRUD operations with golang, JWT, postgres

user-api-golang A CRUD API template for perform operations on users. Written in golang. Components Server: Golang with go-chi as mux and zap for loggi

Dec 26, 2021

Template for depency injection in golang (no libraries)

Go Dependency Injection (No libraries) Project template based on the most common layered architecture style, made to explain how to do dependency inje

Mar 30, 2022

This is a simple GoLang script template.

This is a simple GoLang script template.

Oct 25, 2022

Fleet Manager Golang Template

Fleet Manager Go Template provides a starting point codebase in Go to create your own Fleet Management service

Sep 12, 2022
Comments
  • Refactor directory layouts.

    Refactor directory layouts.

    1. Move controllers to a dedicated directory, separating it with routes, middlewares, etc.
    2. Add response directory to put response structs.

    Signed-off-by: Leo Lu [email protected]

Go-project-template - Template for a golang project

This is a template repository for golang project Usage Go to github: https://git

Oct 25, 2022
Wrapper package for Go's template/html to allow for easy file-based template inheritance.

Extemplate Extemplate is a small wrapper package around html/template to allow for easy file-based template inheritance. File: templates/parent.tmpl <

Dec 6, 2022
Fast, powerful, yet easy to use template engine for Go. Optimized for speed, zero memory allocations in hot paths. Up to 20x faster than html/template

quicktemplate A fast, powerful, yet easy to use template engine for Go. Inspired by the Mako templates philosophy. Features Extremely fast. Templates

Dec 26, 2022
Simple system for writing HTML/XML as Go code. Better-performing replacement for html/template and text/template

Simple system for writing HTML as Go code. Use normal Go conditionals, loops and functions. Benefit from typing and code analysis. Better performance than templating. Tiny and dependency-free.

Dec 5, 2022
A template to build dynamic web apps quickly using Go, html/template and javascript
A template to build dynamic web apps quickly using Go, html/template and javascript

gomodest-template A modest template to build dynamic web apps in Go, HTML and sprinkles and spots of javascript. Why ? Build dynamic websites using th

Dec 29, 2022
Made from template temporalio/money-transfer-project-template-go
Made from template temporalio/money-transfer-project-template-go

Temporal Go Project Template This is a simple project for demonstrating Temporal with the Go SDK. The full 20 minute guide is here: https://docs.tempo

Jan 6, 2022
Go-api-template - A rough template to give you a starting point for your API

Golang API Template This is only a rough template to give you a starting point f

Jan 14, 2022
Golang Service Template

Golang Service Template Golang back-end service template. Using this template, you can get started with back-end projects quickly. Web Framework ORM D

Jun 8, 2022
A general purpose golang CLI template for Github and Gitlab

golang-cli-template A general purpose project template for golang CLI applications This template serves as a starting point for golang commandline app

Dec 2, 2022
Clean arch Golang template project

Template No previous versions, still working on this one to reach v1. API Service for pssword app mobilde based on : https://github.com/bxcodec/go-cle

Sep 15, 2021