Articles by Tuan Nguyen
Golang json omitempty: meaning, zero values, and nested structs
Golang json omitempty and omitempty meaning in encoding/json; golang omitempty with strings, numbers, pointers; why omitempty has no effect omitting nested struct value fields; use pointers for optional objects; go json …
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 os package: Open, Create, WriteFile, and *os.File
Golang os package for files: golang os open and OpenFile, os create golang with os.Create, os writefile golang with os.WriteFile, *os.File reads and append, Stat and errors.Is(os.ErrNotExist), Remove.
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.
Golang io.ReadCloser: Reader+Closer, NopCloser, and read to string
io.ReadCloser golang and golang readcloser: embed io.Reader and io.Closer, io.NopCloser / nopcloser for Readers without real Close, golang io reader examples, and io.readcloser to string with io.ReadAll plus defer Close.
Golang int to int64 and int64 to int conversion
Golang int to int64 and golang convert int to int64 with T conversions; golang int64 to int and int64 to int golang narrowing; go int to int64; golang cast int to int64; strconv round trip; portability when int is 32 …
Convert float64 to int or int64 in Go (cast, round, strconv)
Golang float64 to int and golang float64 to int64: convert with int()/int64() truncation, math.Round for nearest integer, golang convert float to int and golang convert float64 to int safely, plus float64 to int golang …
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 …
GOPATH vs GOROOT: what is GOROOT, go root, and how they differ
Gopath vs goroot and goroot vs gopath: what is goroot (go root / golang goroot), GOPATH for your workspace, why GOPATH and GOROOT must not be the same directory, go env GOROOT and go env GOPATH, modules and GOMODCACHE, …
Golang new error: errors.New, fmt.Errorf, and custom errors
Golang new error and golang create error with errors.New and fmt.Errorf; errors new golang patterns, sentinels, errors.Is, %w wrapping, and custom types implementing error.
Golang append to slice: elements, another slice, and []byte rules
Golang append and append golang: golang add to slice, golang append to slice and golang slice append with variadic ..., golang append slice to slice, go append to array semantics, []byte plus string append, and always …
Golang init function: syntax, rules, and order of execution
Golang init and go init: func init() rules, init order across imports and files, multiple init functions, blank imports, when to use or avoid init(), with spec-aligned examples.
Golang prompt for input: interactive CLI with bufio and fmt
Golang prompt for input and go interactive cli: read lines from stdin with bufio for a go prompt, yes/no prompts, Scanln loops, and validation with strconv; note c-bata go-prompt library vs stdlib for golang prompt and …
Go get specific version and go get version with Go modules
Go get specific version and go get version with modules: go get with version and go get package version using @v1.2.3, go list for go get version of package, go update package to specific version with @latest and …
Golang Time Format: Date, Time, RFC3339, Parse, and Layout Examples
Format and parse time in Go using the reference layout 2006-01-02 15:04:05, time.Now().Format, RFC3339, Z07:00 for UTC as Z, Parse and ParseInLocation, common mistakes with YYYY-MM-DD, and copy-paste layout tables.
go.mod file not found in current directory or any parent directory — fix
Fix go.mod file not found in current directory or any parent directory and go: go.mod file not found errors: how Go walks up for go.mod, cd to module root, go mod init, nested modules, and go get no longer supported …
Convert io.Reader or io.ReadCloser to a String in Go
Drain a golang io.Reader or io.ReadCloser into a string with io.ReadAll and string(b), or stream with strings.Builder and io.Copy or bytes.Buffer.ReadFrom; use strings.NewReader when you need a reader from a string.
Golang remove from slice: delete element by index and while iterating
Golang remove from slice and delete element from slice golang: by index with order, swap-pop without order, first element, and safe patterns while iterating.
Convert a Go Byte Slice to io.Reader (and Reader Back to Bytes)
Turn a Go []byte or byte buffer into an io.Reader with bytes.NewReader, use strings.NewReader for text, then read with io.ReadAll or io.Copy when you need bytes or strings back from a reader.

