Decoding Go Language Source Code: A Deep Dive into go: Directives and the Use of Automation Tools

These go: instructions in the Go source code && go automation tools Developers have a strong tendency to automate repetitive tasks, and this also applies to writing code. Boilerplate code may include operations such as setting up a basic file structure, initializing variables, defining functions, or importing libraries or modules. In some cases, packages provide boilerplate code as a starting point for developers to build from, typically generated after the code behavior has been configured....

January 25, 2024 · 22 min · 4561 words · Xinwei Xiong, Me

Cross Platform Compilation

Preface https://github.com/OpenIMSDK/Open-IM-Server/issues/432 Many places now have requirements for local adaptation of services. Generally, localized platforms provide an arm version of Linux cloud environment for us to deploy services, so it is necessary to build an arm version of the image. Build plan In the above issue, we describe the general construction ideas and solution steps. Let’s take a look at the construction plan. We take the most commonly used amd machine as an example to compile arm....

September 16, 2023 · 14 min · 2788 words · Xinwei Xiong, Me

GoReleaser: Automate your software releases

The goal of GoReleaser is to automate much of the tedious work when releasing software, by using sensible defaults and making it simple for the most common use cases. Preparation: .goreleaser.yaml file: contains all configuration information. (For more information, see Customization) Clean working tree: Make sure the code is up to date and all changes have been committed. SemVer compliant version number (e.g. 10.21.34-prerelease+buildmeta) GoReleaser running steps: The operation of GoReleaser is mainly divided into the following four steps:...

September 16, 2023 · 51 min · 10670 words · Xiong Xinwei, Me

Use Go Tools Dlv

Debugging Go project ::: tip prepare: vscode golang 1.92 ::: demo go mod init test In main.go file package main import ( "fmt" ) // Swap functions func swap(x, y *string) (string, string) { //XOR exchange *x, *y = *y, *x } func main() { fmt.Println("Hello, world!") //Swap functions for i := 0; i < 10; i++ { a := "a" b := "b" swap(&a, &b) fmt.Println(a, b) } } vscode generates tests with one click >gotest for package/function ::: tip They are to generate test units for packages and test units for functions....

February 24, 2023 · 17 min · 3421 words · Xinwei Xiong, Me