[code Chapter] build your own golang framework step by step from scratch

The last article mentioned that the configuration and log have been initialized, and then the database and redis have been initialized. Initialize database I choose xorm for database orm. First, add the corresponding database configuration in config.json and config.go.config.json: "db_config": { "db_host": "127.0.0.1", "db_port": "33 ...

Added by kendallkamikaze on Wed, 22 Jan 2020 17:44:42 +0200

Arrays and slices of go

What is an array? array An array is a sequence of fixed length elements of a specific type. An array can be composed of zero or more elements How to define an array? One way package main import "fmt" func arraytest() { var x [3] int fmt.Println(x) } // Output [0 0 0] func main() { arraytest() } Using quick declaration arr ...

Added by chris1 on Tue, 07 Jan 2020 17:14:01 +0200

[Series] How does Go parse JSON data?

Summary Recently, I fell into a demand pit and just climbed up. There was a serious problem with the evaluation schedule. The following three pictures are very in line with my mood at that time. Talk about needs Estimate Schedule Start drying Why is this so? Here's a brief summary: Dock with third party. Docking across teams. For the first ...

Added by cdjsjoe on Sat, 04 Jan 2020 17:59:27 +0200

The difference between new and make in golang

In golang, both make and new allocate memory, but there are still some differences between them. Only by understanding the differences between them can they be used in appropriate occasions. Simply put, new just allocates memory, not initializes memory; make allocates and initializes memory. The so-called initialization is to assign an initial ...

Added by cljones81 on Tue, 17 Dec 2019 12:02:51 +0200

Go learning note 03 - structure control

Catalog Conditional statement Loop statement Conditional statement Condition statements use the if keyword to determine conditions, such as: func bounded(v int) int { if v > 100 { return 100 } else if v < 0 { return 0 } else { return v ...

Added by nabeel21 on Tue, 03 Dec 2019 10:41:56 +0200

Multitask usage mode

Single task only Global resource loading (initialization), public resource destruction in multitasking // Initialization work // 1. Through init method, it is only executed once, but cannot be called repeatedly // Simulate global configuration type AppConfig struct { Name string IP string Version string } var appconfig *AppConfi ...

Added by stereo on Wed, 27 Nov 2019 11:43:13 +0200

The use of golang rabbitmq

The last article mainly explained the use of queue. Both producer and consumer are directly connected to the queue for message production and consumption. This article mainly describes the use of Exchange. There are several types of Exchange: direct,topic,headers and fanoutLet's talk about the exchange of fanout type. The function is to forward ...

Added by coolen on Mon, 18 Nov 2019 22:20:44 +0200

Add Documents Using Go

brief introduction swagger start Write documentation Function summary Code for current section brief introduction Documentation is essential for API services. Documents, however, are annoying, especially synchronous updates. If you choose handwritten documents, you often forget to update them.Or in the early stages of high-speed development, ...

Added by ztkirby on Sun, 10 Nov 2019 03:16:06 +0200

Go gin API routing Middleware - catch exceptions

SummaryFirst, synchronize the following project overview:Last article shared, routing Middleware - logging, this article we share: routing Middleware - catch exceptions.When there is an exception in the system, it will prompt "system exception, please contact the administrator!" And send the panic alarm email.What is anomaly?The excep ...

Added by djg_uk on Sat, 09 Nov 2019 16:43:57 +0200

Building a continuous deployment on containers and best practices

To understand continuous integration and deployment, you need to understand its components and the relationships between them.The diagram below is the most concise and clear diagram of continuous deployment and integration I've ever seen. picture source Continuous deployment: As shown in the diagram, the development process is as follows:Progr ...

Added by floR on Fri, 08 Nov 2019 05:03:41 +0200