This is a template project to help beginners learn, or to help developers develop some interesting small projects

Go Gin Template Go Report Card MIT

Switch language: 中文|English

Introduction

Use Gin to build an initial template for web applications, which basically involves the technologies and ideas involved in daily development, defines the structure of the project, and provides some simple examples are for use. Of course, we must realize that Go is a relatively open language, and Gin also provides a very concise API for use. Therefore, the structure of the project can also be adjusted according to the actual needs. The standardized structure is only for the team to be able to code in a unified style, to provide the best coding experience.

How To Run

Environment

  1. First, please make sure that Go has been installed on your machine. For the installation method, please refer to the official website https://golang.org/dl/

  2. [TODO] Second, because this project also uses Docker to establish a development environment, if you need to ensure that the Demo runs normally, please make sure that Docker is installed on your machine. For the installation method, please refer to the official website https://www.docker.com/get-started

  3. Of course, if you know exactly what services you need, you can also use self-built services (such as Redis, Mysql, etc.) to replace the test environment provided by Docker

Configuration

The reading of the configuration file in this project follows the following rules:

  • If the config/app.toml configuration file exists, read config/app.toml as the configuration file
  • If it does not exist, use the default configuration file config/default/app.toml

Therefore, it is recommended that you copy config/default/app.toml to config/app.toml and modify config/default/app.toml, so that you can quickly recover after you modify the configuration file by mistake. The content of the configuration file is roughly as follows:

[app]
version = "0.0.1"
name = "Gin Development Template"

[app.filelog]
enable = false
path = "./logs/"

[server]
run_mode = "debug"
port = 8080

···

Running

$ git clone https://gitee.com/axiangcoding/go-gin-template.git
$ cd go-gin-template
$ # [TODO] automatic start docker-compose
$ go run main.go

The running information of the project will appear in your console:

gin-template/api/v1.DemoGet (3 handlers) [GIN-debug] POST /api/v1/demo/post --> gin-template/api/v1.DemoPost (3 handlers) [GIN-debug] GET /swagger/*any --> github.com/swaggo/gin-swagger.CustomWrapHandler.func1 (3 handlers) ">
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /api/v1/demo/get          --> gin-template/api/v1.DemoGet (3 handlers)
[GIN-debug] POST   /api/v1/demo/post         --> gin-template/api/v1.DemoPost (3 handlers)
[GIN-debug] GET    /swagger/*any             --> github.com/swaggo/gin-swagger.CustomWrapHandler.func1 (3 handlers)

Next, visit the address: http://localhost:8080/swagger/index.html, you will see the following interface: image

Finally, you are free to use!

Feature

  • Gin (Web framework)
  • Swagger (Open Doc)
  • Viper (Config)
  • Zap (Log)
  • JWT (Verify)
  • Graceful stop (Server)

Reference

You can see farther by standing on the shoulders of giants

Contact me

Email to [email protected]

Similar Resources

Rental-api - A RESTful-API that allows developers to connect to data about rental properties

Rentals-API is a RESTful-API that allows developers to connect to data about rental properties.

Jan 24, 2022

Minimal bundling for projects that require generation (e.g. SASS to CSS)

staticgen staticgen is a tool that generates file bundles and watches directories for changes. Configuration Project configurations are specified in t

Dec 14, 2021

Tsdev (Zero Config Modern Typescript Projects)

Tsdev (Zero Config Modern Typescript Projects) Motivation I really like the idea behind https://github.com/jaredpalmer/tsdx but I find it uses older t

Jun 29, 2022

Kuncie Cart - An implementation of Kuncie cart in Golang projects

Kuncie Cart - An implementation of Kuncie cart in Golang projects

Jan 21, 2022

Package GoEagi provides some fundamental functionalities that work with Asterisk's EAGI

GoEagi Package GoEagi provides some fundamental functionalities that work with Asterisk's EAGI. It has the following features: Audio Streaming Google'

Dec 16, 2022

A small site builder for the Gemini protocol

🐟 Flounder A lightweight platform to help users build simple Gemini sites over http(s) and serve those sites over http(s) and Gemini Flounder is in A

Dec 7, 2021

This is a small API that provides basic REST endpoints to shorten a URL

This is a small API that provides basic REST endpoints to shorten a URL

This is a small API that provides basic REST endpoints to shorten a URL, get information about the URL, update the URL, and get statistics on most accessed URLs.

Nov 16, 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

Oct 19, 2022

Api-e-commerce - Golang fiber e commerce template

Golang fiber e commerce template Stack Golang v1.17 Fiber v2.24.0 Validation v10

May 7, 2022
Comments
  • Add CodeQL workflow for GitHub code scanning

    Add CodeQL workflow for GitHub code scanning

    Hi axiangcoding/ax-web!

    This is a one-off automatically generated pull request from LGTM.com :robot:. You might have heard that we’ve integrated LGTM’s underlying CodeQL analysis engine natively into GitHub. The result is GitHub code scanning!

    With LGTM fully integrated into code scanning, we are focused on improving CodeQL within the native GitHub code scanning experience. In order to take advantage of current and future improvements to our analysis capabilities, we suggest you enable code scanning on your repository. Please take a look at our blog post for more information.

    This pull request enables code scanning by adding an auto-generated codeql.yml workflow file for GitHub Actions to your repository — take a look! We tested it before opening this pull request, so all should be working :heavy_check_mark:. In fact, you might already have seen some alerts appear on this pull request!

    Where needed and if possible, we’ve adjusted the configuration to the needs of your particular repository. But of course, you should feel free to tweak it further! Check this page for detailed documentation.

    Questions? Check out the FAQ below!

    FAQ

    Click here to expand the FAQ section

    How often will the code scanning analysis run?

    By default, code scanning will trigger a scan with the CodeQL engine on the following events:

    • On every pull request — to flag up potential security problems for you to investigate before merging a PR.
    • On every push to your default branch and other protected branches — this keeps the analysis results on your repository’s Security tab up to date.
    • Once a week at a fixed time — to make sure you benefit from the latest updated security analysis even when no code was committed or PRs were opened.

    What will this cost?

    Nothing! The CodeQL engine will run inside GitHub Actions, making use of your unlimited free compute minutes for public repositories.

    What types of problems does CodeQL find?

    The CodeQL engine that powers GitHub code scanning is the exact same engine that powers LGTM.com. The exact set of rules has been tweaked slightly, but you should see almost exactly the same types of alerts as you were used to on LGTM.com: we’ve enabled the security-and-quality query suite for you.

    How do I upgrade my CodeQL engine?

    No need! New versions of the CodeQL analysis are constantly deployed on GitHub.com; your repository will automatically benefit from the most recently released version.

    The analysis doesn’t seem to be working

    If you get an error in GitHub Actions that indicates that CodeQL wasn’t able to analyze your code, please follow the instructions here to debug the analysis.

    How do I disable LGTM.com?

    If you have LGTM’s automatic pull request analysis enabled, then you can follow these steps to disable the LGTM pull request analysis. You don’t actually need to remove your repository from LGTM.com; it will automatically be removed in the next few months as part of the deprecation of LGTM.com (more info here).

    Which source code hosting platforms does code scanning support?

    GitHub code scanning is deeply integrated within GitHub itself. If you’d like to scan source code that is hosted elsewhere, we suggest that you create a mirror of that code on GitHub.

    How do I know this PR is legitimate?

    This PR is filed by the official LGTM.com GitHub App, in line with the deprecation timeline that was announced on the official GitHub Blog. The proposed GitHub Action workflow uses the official open source GitHub CodeQL Action. If you have any other questions or concerns, please join the discussion here in the official GitHub community!

    I have another question / how do I get in touch?

    Please join the discussion here to ask further questions and send us suggestions!

GoTrue is a small open-source API written in Golang, that can act as a self-standing API service for handling user registration and authentication for Jamstack projects.
GoTrue is a small open-source API written in Golang, that can act as a self-standing API service for handling user registration and authentication for Jamstack projects.

GoTrue is a small open-source API written in Golang, that can act as a self-standing API service for handling user registration and authentication for Jamstack projects.

Dec 13, 2021
A rest api to help automate some of the things Matt does

AutoMatt A rest api to help automate some of the things Matt does run in docker for dev go build && \ docker build -t automatt:latest . && \ docker ru

Dec 6, 2021
Super lightweight, easy-to-develop, general purpose golang framework

Super lightweight, easy-to-develop, general purpose golang framework ??

Jun 14, 2022
Tts - A project takes advantage of a server to run compute some audio file from text you send it

Text to Speech Hey this project takes advantage of a server to run compute some

Jan 26, 2022
Kratos Project Template for golang

Kratos Project Template Install Kratos go get -u github.com/go-kratos/kratos/cmd/kratos/v2@latest Create a service # Create a template project kratos

Dec 11, 2021
Ares-admin - Kratos Project Template For Golang

Kratos Project Template Install Kratos go get -u github.com/go-kratos/kratos/cmd

Feb 15, 2022
Broilerplate - A template project for new Go web backend applications
Broilerplate - A template project for new Go web backend applications

Broilerplate A template project for new Go web backend applications. Can be used

Mar 28, 2022
Nada is a JS runtime, just like Nodejs. The difference is that Nada allows JS developers to easily achieve millions of concurrent applications.

Nada is a JS runtime, just like Nodejs. The difference is that Nada allows JS developers to easily achieve millions of concurrent applications. It also adds some new enhancements to THE JS syntax (types, interfaces, generics) that fundamentally address JS's perennial complaints.

Jul 11, 2022
Give developers an easy way to create and integrate bank processing into their own software products
Give developers an easy way to create and integrate bank processing into their own software products

Community · Blog moov-io/bankcron Moov's mission is to give developers an easy way to create and integrate bank processing into their own software pro

Sep 27, 2022
Use of Advent of Code challenges to perform pyhton and learn Go language

Scripts in Python and Go language made to perform Advent of Code 2021 challenges

Jan 3, 2022