Articles by Tuan Nguyen
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 …
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.
Golang HTML to Text: Strip Tags, Parse HTML, and Convert HTTP Body
Convert HTML to text in Go, strip HTML tags, read HTTP response body with io.ReadAll, parse HTML with golang.org/x/net/html, extract body text or body HTML, and know when html2text or bluemonday fits better.
Golang URL Encode Decode: QueryEscape, PathEscape, and Query Params
URL encode and decode strings in Go with net/url: QueryEscape, QueryUnescape, PathEscape, PathUnescape, url.Values, ParseQuery, and url.Parse with RawQuery.
Golang Type Assertion: Interface, Concrete Type, and Type Switch Examples
Learn how type assertion works in Go on interface values: concrete types, x.(T) vs comma-ok, panic rules, type switches, and how assertion differs from type conversion.
Golang remove backslash from string
Remove backslash from a string in Go with strings.ReplaceAll or strings.Replace, including raw literals and optional cleanup. Related: golang remove substring and golang remove characters.
Golang reflect and golang reflection: Type, Value, Kind, Set, MakeFunc, StructOf
Golang reflection with reflect.TypeOf and reflect.ValueOf, Kind vs Type, struct fields and tags, settable values and Set, reflect.New, MakeSlice MakeMap MakeChan, MakeFunc wrappers, StructOf limits, Value.Call, …
Go json.Unmarshal: Structs, Maps, Slices, null, RawMessage, and Errors
Deep guide to json.Unmarshal in Go: []byte and pointer rules, structs with tags, maps and float64 numbers, slices, nested JSON, any decoding, null, json.RawMessage, unknown fields vs Decoder.DisallowUnknownFields, …
Golang Parse JSON: String, File, Struct, Map, and Decoder Examples
Learn how to parse JSON in Go using encoding/json: JSON strings, files, HTTP bodies, structs, maps, nested data, json.Unmarshal, json.Decoder, and common errors.
How to Uninstall Golang (Go Compiler) on Linux, macOS, and Windows
Learn how to uninstall Golang (Go compiler) on Linux, macOS, and Windows. This guide explains how to remove Go installed using tarball archives, package managers, Homebrew, or installers, including cleaning environment …
Best IDE for Golang: VS Code, GoLand, Neovim, Zed, and More
Compare the best IDEs and editors for Go development: VS Code, GoLand, Neovim, Zed, LiteIDE, Sublime Text, and Emacs—use cases, trade-offs, setup checklist, and legacy tools to avoid.
How to PROPERLY upgrade GO version in Ubuntu? [SOLVED]
Step by step instructions to upgrade go in Linux, Windows and MacOS.
30+ Golang Interview Questions and Answers
30+ golang interview questions and answers for Junior (Beginner), Middle and Advanced (Experienced) professionals
Golang JWT (Json Web Token) Examples
In this tutorial we learned how to create HTTP Server and Client using golang JWT (JSON Web Token)
Golang AWS Lambda Example [In-depth Tutorial]
In this series, we will learn how to set up a serverless framework example for Golang and AWS Lambda. First of all, we are going to walk through how to create
Golang vs Rust | Which language to choose in
Comparing different aspects of golang with rust programming language
Learn Golang Chi to Master the Craft of Web Services
Discover the transformative power of Golang Chi in web development. Our comprehensive guide provides insights and practical knowledge, equipping you to create robust, flexible, and efficient web services, mastering the …
How to use goroutine return value?
In this example we will use golang channel to fetch the goroutine return value:
Golang SQLite3 Tutorial [With Examples]
Golang sqlite tutorial with CRUD Operation. Executing commands on SQLITE database, Select statement, Insert, Read and Delete Operation with examples
Golang Viper: The Unsung Hero of Configuration Wizards
golang viper tutorial to source YAML, JSON or ENV files and get variables. Set default values for empty or missing variables using viper.SetDefault
Managing golang connection pool
In the previous article, I introduced to you the ways to work with SQL in Golang. You don't need to change the defaults for the sql.DB connection pool for the
Golang generate random string Examples
Multiple examples covering golang generate random string using rand function. Generate alphanumeric, special characters, uppercase, lowercase strings
How to check if struct is empty in GO?
This article describes a few methods for determining whether a struct in Go is empty. It includes structs having fields that are comparable and

