• [gin learning notes] 07 get to know grom and use Gorm for database operation


    This article learning video https://www.bilibili.com/video/BV1Bz411v78U/?spm_id_from=333.788 Chinese Gorm official document https://jasperxu.com/Programming/Golang/GORM/Another document https://learnku.com/docs/gorm/v2/index/9728 What is ORM An auxiliary tool for database operation Map between our go structure and the database, so that we can intuitively reflect the relationship of the database and the content of the table on the structure You can add, delete, modify and […]

  • Gin middleware recommendation


    Welcome to the original textclick, if necessary, in yourginUsed in the project, pleaseClick the link, find the corresponding warehouse link, and usego get -uInstall it Restgate – secure authentication of rest API endpoints Staticbin – Middleware / handler for providing static files from binary data Gin CORS – Official middleware for CORS gin Gin CSRF […]

  • Building a full-featured Web application with golang + Vue


    Recently, the epidemic is at home and there is a lot of free time. Sort out the golang project written beforeWeave, added some functions and front-end implementation. As a web application template, it has complete functions. Now I summarize some problems and project characteristics encountered in the development process. introduce Weave is based onGo+VueThe implemented […]

  • Processing scheme of gin parsing JSON format data error


    Write the interface to test. There is no page yet. Test the interface directly. use c.BindJSON(&req) Errors are always reported. The general error information is as follows: err=”invalid character ‘-‘ in numeric literal” This is because my interface requires parameters to be passed to the background in JSON format. As a result, the test colleagues […]

  • Gin get JSON body operation of post request


    I won’t talk more nonsense. Let’s look at the code directly~ The code is as follows type KDRespBody struct { Errcode int `json:”errcode”` Desc string `json:”description”` Data []services.KdSearchBack `json:”data”` } var reqInfo KDRespBody err := c.BindJSON(&reqInfo) if err != nil { log.Info(err) c.JSON(200, gin.H{“errcode”: 400, “description”: “Post Data Err”}) return } else { fmt.Println(reqInfo.Data) } […]

  • Introduction to golang gin framework (II)


    catalogue preface text 1、 Define the interfaces of get, post, put, patch, delete and options 2、 Parsing parameters in path ending preface Gin is an HTTP web framework implemented in pure golang language. Gin’s interface design is simple and has high performance. Now it is widely used. The last article introduced the basic usage of […]

  • Use of gin framework (III) — user registration


    Create a model directory under gin demo and a user directory under it Go to write the structure of user user. The contents of go are as follows: package model // User type User struct { Id int ` Gorm: “primarykey” ` // set as primary key // not null ` Gorm: unique string ‘// […]

  • Installation, testing and introduction of golang development micro framework gin


    catalogue summary install test Guide Package step Toggle output format Status code Examples front end summary Gin is a golang micro framework with elegant encapsulation and friendly API. It is fast and flexible, fault-tolerant and convenient. Gin’s own net / HTTP is simple enough and its performance is very good Gin Download: https://github.com/gin-gonic/ginEnglish documents: https://gin-gonic.com/docs/ […]

  • Detailed explanation of practical examples of simple restful style API implemented by gin and MySQL


    catalogue It works main.go Compile and run database Curd addition, deletion, modification and query increase check Query list query Query a single record queryrow change Delete Organization code Packaging model method Handler function Organization project Database processing Data model encapsulation handler route Packet routing App entry summary We have learned about golang’s gin framework. For […]

  • Detailed explanation of basic gin routing of golang microservice framework


    catalogue summary 1. Basic routing 2. Routing parameters Get all parameters of URL path Get URL path single parameter Gets the parameter specified in the URL Gets the value of the parameter that specifies the default value summary Routing is to customize the URL address and execute the specified function. A good routing definition can […]

  • The relationship between gin and net / HTTP


    Gin is one of the most widely used frameworks in go. Understanding the principle of gin framework will help us to better use gin. Reading the source code of this series of gin will gradually explain the principle of gin. Welcome to follow-up articles. Gin overview To understand gin, you need to understand the following […]

  • Golang web development based on gin: detailed explanation of routing examples


    Gin is an HTTP network framework written in golang. It is similar to Martini’s API and has better performance. In the field of golang web development, it is a very popular web framework. Start a gin web server Use the following command to install gin go get -u github.com/gin-gonic/gin Add dependencies to your code import […]