Golang integrates RocketMQ

RocketMQ related knowledge summary What is RocketMQ RocketMQ is an open source MQ framework from Alibaba. It is widely used in different business scenarios and has very good ecosystem support. It supports transaction messages, sequential messages, batch messages, scheduled messages, message traceback and other functions. RocketMQ core concepts Name Service (NameServer): It can be understood […]

Golang standard library: bytes package – byte slice byte array convenient operation

2.2 bytes – byte slice convenient operation This package defines some convenience operations for manipulating byte slices. Because strings can be represented as []byte, the functions and methods defined by the bytes package are very similar to the strings package, so the explanation will be similar to the strings package and can even be referred […]

“Dependency Injection” of golang library

Article directory 1. Write at the front 2. Dependency injection 2.1 Usage scenarios 2.2 Framework comparison 3. Examples of fx framework usage scenarios 3.1 Example 3.2 golang native library 3.3 fx library 3.4 Comparison 3.4.1 Comparison of the above two implementation methods 3.4.2 About over-design 3.4.3 Enlightenment 4. Thoughts 5. References 1. Write at the […]

Golang os package: process creation and termination, running external commands

The os package and its subpackage os/exec provide methods for creating processes. Generally, the os/exec package should be used first. Because the os/exec package relies on the key process creation APIs in the os package, for ease of understanding, we first discuss the process-related APIs in the os package. part. Creation of process In Unix, […]

nacos configuration center docker deployment, configuration and goLang integration use

Why a configuration center is needed Usually when we write a demo, or a single application, there will be a configuration file, whether it is a json file or a yaml file, which contains redis, mysql, es and other information. If we modify the configuration file, we often A restart is required. In order to […]

Implementing time wheel algorithm from zero to one based on golang (3)

Introduction This article is compiled with reference to Mr. Xiao Xu’s related blogs. The project address is: https://github.com/xiaoxuxiansheng/timewheel/blob/main/redis_time_wheel.go. Mainly to improve the process and record personal study notes. Distributed version implementation In this chapter, we discuss how to implement a distributed version of the time wheel based on redis to meet the requirements of the […]

golang gorm implements addition, deletion and modification of general single tables through generics

golang gorm implements general single table addition, deletion and modification through generics No nonsense, just jump into the code If you want to achieve universality, you must first implement universal query, which can be achieved by passing map func Where(where map[string]interface{}) func(db *gorm.DB) *gorm.DB { return func(db *gorm.DB) *gorm.DB { dbTmp := db for ko, […]

Request parameter processing of Golang Gin framework

How to obtain the data in the request through various methods in Gin. Gin obtains route parameters through the c.Param() method, which are variables defined in the route. For example: r.GET(“/user/:id”, func(c *gin.Context) { id := c.Param(“id”) c.String(http.StatusOK, “id=%s”, id) }) But if you need to get multiple parameters, you can use the c.Params property, […]