Giter Site home page Giter Site logo

golang-scaffold's Introduction

中文文档

golang-scaffold

This is a scaffold that integrates all the basic components needed for fast startup of a Golang web server.

Demo

Recommend using VsCode.

VsCode

  • Create custom configuration based on conf/template.yaml.
  • Configure environment variables, which can be configured in vscode's launch.json:
{
    "config_path": "your config file path"
}
  • Click "Launch Server" and you will see the Demo service start on your local 8080 port.

Start

  • Create custom configuration, refer to template.yaml.
  • Configure environment variables for the configuration file:
{
    "config_path": "your config file path"
}
  • Replace the scaffold package name with your own package name:
replace github.com/KAMIENDER/golang-scaffold with your pkg name

DataBase

  • Add your database table.
  • Modify infra/database/mysql/gen_tool/mysql_gen.go and add the code for generating configuration corresponding to your database. Refer to the user table generation code that already exists.
  • Execute infra/database/mysql/gen_tool/mysql_gen.go. It will connect to your database, generate corresponding Golang structures and CURD code based on your database table information.

User Auth

The most basic user table: ddl/user.sql

  • Global search "Add user information" and generate the code for adding your user information and corresponding operations based on the annotation prompts.
  • After modifying user.sql, do not forget to execute the corresponding table creation SQL in your database, and then execute infra/database/mysql/gen_tool/mysql_gen.go to update your user structure.
  • By default, /auth/* is used as the path for authentication.
  • For interfaces that require user login verification, call the auth.WrapHandler method to encapsulate them before configuring gin.

Dependency

Auth:

AuthBoss: https://github.com/volatiletech/authboss

ORM

gorm: https://github.com/go-gorm/gorm

gen: https://gorm.io/zh_CN/gen/

Web

gin: https://github.com/gin-gonic/gin

Pay

gopay: https://github.com/go-pay/gopay

Email

gmail: gopkg.in/gomail.v2

Log

zap: https://github.com/uber-go/zap

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.