Dockertest: A Fast Way to Set Up Integration Test Environments dockertest
Go
All posts
Go High-Performance Programming Handbook (Long Read) Common data structures Reflection is nice, but don’t overuse it Prefer strconv over fmt A small amount of repetition is not worse than reflection Use …
How to Choose a Go File Reading Approach Go provides one-shot methods for reading file content: os.ReadFile and ioutil.ReadFile. Starting from Go 1.16, ioutil.ReadFile is equivalent to os.ReadFile. The pros …
Struct Tricks Every Gopher Should Know NoCopy $ go vet aaa.go # command-line-arguments ./aaa.go:7:14: test passes lock by value: sync.WaitGroup contains sync.noCopy ./aaa.go:15:10: call of test copies lock …
Go AES Encryption and Decryption in Three Modes (CBC/ECB/CFB) How to encrypt a file using Go
How Go Reads a 16GB File in 25 Seconds Reading 16GB File in Seconds, Golang After opening the file, we have two options: Read the file line by line, which reduces memory pressure but takes more time. Read the …
Bind JSON with jsoniter in Gin simple go build -tags=jsoniter ./... custom implement BindingBody interface // github.com/gin-gonic/gin@v1.6.3/binding/binding.go:36 // Binding describes the interface which …
Golang os/exec usage (notes) Add extra environment variables before running a command cmd := exec.Command("programToExecute") additionalEnv := "FOO=bar" newEnv := append(os.Environ(), additionalEnv) cmd.Env = …
Golang benchmarks Basics Benchmarks are used for performance testing. Functions should import the testing package and define functions that start with Benchmark. The parameter type is testing.B, and the target …
[Translated] Go inline strategy and limitations Go: Inlining Strategy & Limitation Visualizing memory management in Golang Understanding Allocations in Go package main import "fmt" func main() { n := …
Go Modules workflow for private Git repositories go env -w GOPRIVATE=github.com/appleboy go env -w GONOPROXY=github.com/appleboy go env -w GONOSUMDB=github.com/appleboy git config --global …
Customize route log format Run multiple services with Gin XML, JSON, YAML, and ProtoBuf rendering (output formats) Customize route log format default [GIN-debug] POST /foo --> main.main.func1 (3 handlers) …