Articles by Tuan Nguyen
Golang URL query parameters: url.Values, encoding, and reading requests
Golang url values and url.Values.Encode to add query parameters; golang http request parameters from r.URL.Query; golang url parameters with Set and Add; avoid raw fmt.Sprintf for untrusted strings. Related HTTP overview …
Golang HTTP POST JSON: send a post request with a JSON body in Go
Golang http post json and golang post request with json body using net/http: http.NewRequest with bytes.Reader, Content-Type application/json, json.Marshal, and a minimal server decode with json.Decoder; httptest example …
Golang performance and speed: how Go compares and why it is fast
Golang performance versus Java, Python, Node.js, and C; why the Go language feels fast for servers; golang performance benchmark with go test; golang closure performance basics; links to official docs and community …
Go pass by value or reference: pointers, slices, and maps in Go
Is go pass by value or reference: Go passes arguments by value; golang pass by reference means passing pointers. go pass by value for structs; slices and maps alias shared data. golang pass by reference or value, golang …
Golang print struct: fmt verbs, pretty JSON, and type names
Print struct golang and go print struct with fmt.Printf verbs (%v %+v %#v), golang pretty print struct via encoding/json, golang print type of variable with %T and reflect.TypeOf, fmt.Stringer, and optional go-spew.
Golang queue: FIFO slice, container/list, and channels
Golang queue implementation for FIFO: slice append and reslice, golang fifo queue memory notes, container/list, buffered channel go queue, generics helpers, peek and empty checks, concurrency hints, and links to channels …
Golang prompt and interactive CLI: stdin, passwords, promptui, survey
Golang interactive CLI and golang prompt for input with bufio; golang.org/x/term ReadPassword with os.Stdin.Fd; promptui golang and survey; go-prompt (c-bata); notes on TTYs and cross-platform terminals.
Golang read file, update in place, and overwrite safely
Golang read file and golang read entire file with os.ReadFile; golang open file and os.OpenFile flags; golang overwrite file and append; update one field of big file golang via temp file rename or streaming; WriteAt …
Golang multiline string and reading multiple lines from stdin
Golang multiline string with raw backticks and escapes; golang read stdin and golang read line from stdin using fmt.Scan tokens, bufio.Reader ReadString, and bufio.Scanner; EOF and token size notes; not golang multiline …
Golang random bool and random boolean: math/rand and crypto/rand
Golang random bool and golang random boolean with math/rand Intn and Float64, golang rand local source for tests, random boolean generator patterns in Go, and crypto/rand when you need unpredictable bits—not Python or …
Delete keys from a map in Go with delete()
Remove entries from a map in Go with the built-in delete(map, key); deleting a missing key is safe; use the comma-ok form first when you want to log or branch on absent keys.
Golang print type: %T, reflect, and type switches
Go print type and golang print type of variable with fmt %T; golang get type via reflect.TypeOf and Kind; pointers, interface{}, and nil; type switches; golang print object as dynamic concrete type.
Golang math pow: power in Go with math.Pow
golang math pow and go math.pow with math.Pow(x,y float64); golang power examples, integer casts and overflow pitfalls, special cases from pkg.go.dev, and alternatives for exact integer exponentiation.
Golang pad string and numbers: fmt padding, leading zeros, and floats
Golang string padding and go padding with fmt.Printf and Sprintf: golang pad string with spaces or zeros, golang format int with leading zeros, golang format float width and precision; optional golang.org/x/text/number.
Golang get current directory, cwd, and path: os.Getwd, Getwd, Executable
Golang get current directory and golang get cwd: os.Getwd for golang get current working directory and golang get pwd, golang print current directory, golang get current path with filepath.Abs, go get current directory …
go-memdb and go memdb: in-memory database for Golang
HashiCorp go-memdb (mem db): golang in memory database with MVCC, schema and id primary index, Txn insert query LowerBound Get First, delete and DeleteAll; not SQL or DynamoDB.
Default and optional parameters in Go (patterns, not language syntax)
Go has no default parameter values at compile time; use zero-value checks, variadic trailing arguments, a struct of fields, or a map[string]any with defaults applied in the function body.
Fix Go compiler errors: declared and not used, imported and not used
Fix declared and not used and imported and not used in Go: remove dead code, use the blank identifier for side-effect imports, and avoid := shadowing in branches so the outer variable is actually assigned.
Golang math package: MaxInt32, MinInt64, Pi, and float64 APIs
Golang math package and pkg.go.dev math docs: math.MaxInt32 math.MinInt32 math.MaxInt64 math.MinInt64 constants, math.MaxInt math.MinInt, Pi and float64 functions, quadratic example, math/big math/bits math/cmplx …
Copy or Clone a Map in Go (Shallow vs Deep)
Copy or clone a map in Go: a new map with a range loop duplicates keys but may share slice, map, or pointer values (shallow copy); duplicate nested data with copy(), JSON marshal/unmarshal, or type-specific logic for a …
Golang length of map: len, nil maps, and counting nested values
Golang length of map and golang map len with builtin len; golang get length of map and go length of map for key count; nil map length zero; golang size of map vs counting nested slice values with range.
Golang hello world: first program, go mod init, and go run
Golang hello world and go hello world: hello world golang program with package main, hello world in golang and go language hello world using fmt.Println, golang hello world example with go mod init, go run and go hello …
Golang packaging: modules, package structure, and naming conventions
Golang packaging with Go modules and golang package structure; golang package naming convention and exports; import paths, internal, cmd layout; golang package design and adding dependencies—go packages tutorial style.
Stop goroutines in Go: cancellation, context, and clean shutdown
Cooperative goroutine shutdown in Go: no kill API, done channels, context cancel and timeouts, worker drains, pipeline-style leaks, WaitGroup, defer cleanup, and cheat sheet vs force kill.
Split a string in Go: strings.Split, Fields, Cut, and SplitN
strings.Split and SplitN, Fields for whitespace, Cut for the first separator, cleaning empty tokens and TrimSpace, CSV caveats with encoding/csv, Split vs regexp.Split, and common mistakes.
Go string interpolation: fmt.Sprintf, verbs, and alternatives
Go has no f-strings or ${} interpolation; use fmt.Sprintf and format verbs, Printf vs Sprintf vs Sprint, number padding and bases, struct verbs, Builder and text/template alternatives, and common fmt mistakes.
Golang log to file, stdout, and syslog with the standard log package
Golang log to file with os.OpenFile and log.SetOutput; golang log to file and stdout using io.MultiWriter; golang log syslog on Linux; go import log and golang log example; concurrency-safe default log.Logger.
Go functions with multiple types: `any`, type switches, and generics
Golang function parameter multiple types: use any/interface{} with a type switch, golang function types with type parameters (generics), go function types and golang func type constraints, plus golang pass type as …
Golang os exit, defer, and why deferred functions are not run
Golang os exit defer: os.Exit golang behavior matches pkg.go.dev os Exit — program terminates immediately and deferred functions are not run; patterns to run cleanup before exit, go os.exit deferred functions official …
Golang os.Stat: file metadata, FileInfo, and os.ErrNotExist
Golang os.stat and golang os stat: os.Stat returns fs.FileInfo (name, size, mode, mod time, IsDir); *File.Stat; errors.Is(err, os.ErrNotExist); os.Lstat vs Stat; PathError. Related os package file I/O.

