Skip to content
Ricky
English

Search

Searching… No matching pages. Matching pages are listed below. Search is unavailable. Please try again.

Go

All posts

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 …

2 minutes

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 …

2 minutes

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 …

3 minutes

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 …

2 minutes

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 = …

1 minute

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 := …

3 minutes

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) …

3 minutes