Articles by Tuan Nguyen
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.
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 reverse range and iterate a slice backwards
Golang reverse range and golang range reverse with a backward index loop; golang range backwards using forward range and remapped index; golang iterate over slice and golang iterate slice backwards; golang reverse slice …
Golang split string and assign to variables: strings.Split, Fields, and Cut
Golang split string and golang string split with strings.Split and strings.Fields; strings split golang and go split string; golang split string into two variables with strings.Cut or slice indexing; net.SplitHostPort …
Golang set cookie and golang http cookie with net/http
Golang set cookie with http.SetCookie and http.Cookie, golang http cookie headers, golang cookies and cookie golang reads via Request.Cookie, Path Domain MaxAge Expires SameSite Secure HttpOnly, order before Write, curl …
Golang iterate over array: range and for loops with len
Golang iterate over array and golang array loop with for range; golang for loop array and golang loop through array using len; go iterate over array and iterate over array golang with index or values only.
Get Current Time in Milliseconds in Go (UnixMilli and Alternatives)
Convert time.Time to Unix milliseconds with UnixMilli, derive ms from UnixNano, or use Duration.Milliseconds after Sub; know int64 range limits from the time package docs.
FlashDB in Go: in-memory key-value store with optional persistence
FlashDB golang tutorial: an in memory database golang option and golang key value store with Redis-style types. Covers go in memory database setup, transactions, string SET/GET/DELETE, disk vs pure memory, and links for …
Golang nil checks: pointers, interfaces, slices, and empty structs
Golang check if nil for pointers and maps; golang null pointer with == nil; check if slice is empty golang (len vs nil); golang check if struct is empty (not nil—reflect.IsZero); golang check if interface is nil …
Go HTTPS Client: Skip TLS Verify (InsecureSkipVerify) and Safer Options
Use tls.Config InsecureSkipVerify on a dedicated net/http Transport for golang http client skip tls verify only in dev; prefer fixing golang ssl certificate trust with RootCAs instead of golang disable ssl verification …
Golang seek on files: os.File.Seek and whence constants
Golang file seek and go file seek with (*os.File).Seek: io.SeekStart, io.SeekCurrent, io.SeekEnd, temp-file examples, and bytes.Reader for in-memory golang seek.
GraphQL in Go: golang graphql tutorial, examples, and HTTP server
Graphql golang tutorial and golang graphql example with github.com/graphql-go/graphql: schema, resolvers, graphql.Do, context, HTTP handler and Playground, go graphql patterns, graphql golang vs REST, and graphql mongodb …
Golang bool to string: FormatBool, Sprintf, and string to bool
Golang bool to string and bool to string golang: strconv.FormatBool for golang convert bool to string, golang sprintf bool with fmt.Sprintf %t or %v, golang string to bool with strconv.ParseBool, go bool to string …
Golang sort slice and array: Ints, Slice, SliceStable, descending
Golang sort slice and go sort slice: sort.Ints, sort.Strings, golang sort array with a slice view, sort.Slice and sort.SliceStable, golang sort descending and reverse slice golang, sort.Sort with IntSlice and …
Golang Run Function at Intervals: Ticker, Sleep, and Cron Examples
Run repeated tasks in Go with time.NewTicker and time.Sleep, stop loops with context, avoid overlapping runs, and use robfig/cron/v3 for wall-clock schedules.
Golang const array: why Go has no constant slices, and what to do instead
Golang const array and golang constant array: Go constants are only numbers, strings, booleans, and complex values built from those—no golang constant slice or const array type; patterns for golang const string array, go …

