Articles by Deepak Prasad
Golang base64 encode and decode with encoding/base64 and JSON
Golang base64 and base64 golang: StdEncoding EncodeToString DecodeString, URLEncoding, padding; golang base64 decode and base64 decode golang; golang json prevent encoding byte to base64 when json.Marshal treats []byte …
Golang escape backslash and escape string: raw literals vs "quoted"
Golang escape string and go escape string: golang escape backslash with doubled backslash in double-quoted strings, golang escape characters in interpreted literals, raw string literals for paths, and golang escape …
Golang array of structs and slice of structs: declare, init, iterate
Golang array of structs and golang struct array: [n]T fixed array vs []T slice, golang initialize array of structs with literals or loops, golang make array of structs with make, golang list of structs and go array of …
Golang sed and awk examples from Go with os/exec
Golang sed and go sed: call sed and awk from Go with os/exec, stdin pipes, temp files, and notes on in-place edits and golang execute shell command patterns.
Remove or Delete Elements from a Slice in Go (First, Last, by Index)
Remove the first or last element from a slice in Go, delete by index while keeping order or in O(1) with swap-and-truncate, drop a run of elements, and use slices.Delete on Go 1.21+.
Golang cast to string: int, any, and bool with strconv and fmt
Golang cast to string and go cast to string: golang int to string and convert int to string golang with strconv and fmt; golang convert any to string and golang cast any to string with type switches and fmt.Sprint; bool …
Access a Go variable from another package: exports, imports, and globals
Golang global variables across packages: package-level vars with an exported name (capital letter), import path module/subpkg, golang declare global variable in util and read from main; why main cannot be imported and …
Golang fsnotify: Watch File and Directory Changes in Go
Use fsnotify in Go to watch files and directories, handle create/write/remove/rename events, watch parent directories for single files, handle symlinks, debounce noisy saves, and avoid common watcher mistakes.
Golang read file into string or variable: os.ReadFile, embed, Open
Golang read file into string and read file golang: os.ReadFile for golang read file to string, go read file to string and []byte, //go:embed for build-time content, os.Open with io.ReadAll; notes for golang read from …
Go map to struct: convert map[string]any and round-trip with structs
Golang map to struct and golang convert map to struct: map[string]any (map string interface) to struct via json.Marshal or mapstructure, manual loops, reflect; plus convert struct to map golang with JSON for map to …
Go const map and constant map: Why They Are Not Allowed and What to Use Instead
Go does not allow golang const map or golang map const literals: constants must be compile-time values of allowed types. Use a golang global map with var and init, getters over unexported maps, or functions that return …
Go map to JSON: convert, print, and parse back with encoding/json
Golang map to JSON and JSON string: json.Marshal and string(bytes) to convert map to json golang, MarshalIndent and Encoder to print map as JSON, then json.Unmarshal for json to map golang (map[string]any) with …
Create a Go Module: go mod init, go.mod, and a Small Example
Learn golang create module workflow with go mod init to generate go.mod, pick a golang module name, enable modules by default, and add a nested package plus tests—without relying on GOPATH src layout.
Golang return multiple values from a function
Golang return multiple values and go function return multiple values: syntax, two-value returns, mixed types, blank identifiers, (T, error), and named results.
Golang return error: create, wrap, and check errors in Go
Golang return error and go return error: the error interface, errors.New and fmt.Errorf, if err checks, wrapping with %w, errors.Is and errors.As, and turning an error into a string.
Go Type Casting: Conversions, Assertions, and Interface to Struct
Golang cast and go cast usually mean explicit type conversion (numeric) or type assertion from any: golang type casting vs strconv for strings, safe v.(T) and golang cast interface to struct with value or pointer types.
Golang remove duplicates from slice: dedupe and unique values
Golang remove duplicates from slice: preserve order with a map, sort then Compact for sorted unique, counts with map, and the XOR trick for one odd-count value.
Golang Variadic Function: ... Syntax, Varargs, and Slice Examples
Variadic functions in Go use ...T for the last parameter (varargs), behave like []T inside the body, and accept slice arguments with slice.... Compare ... at define vs call, mix fixed parameters, ...any, and common …
JavaScript setTimeout(): Delay Code Execution
Learn JavaScript setTimeout() with delay examples, clearTimeout(), callback arguments, async behavior, and common mistakes in browsers and Node.js.
Check if a Go Channel Buffer Is Full or Empty (len, cap, select)
Use len and cap on buffered Go channels to detect full or empty buffers, try a send with select and default, and know why unbuffered channels and “is it closed?” need different patterns.
Cannot use import statement outside a module
Fix SyntaxError cannot use import statement outside a module in Node.js, browsers, and AWS Lambda. Use type module, .mjs, script type=module, and avoid ERR_MODULE_NOT_FOUND confusion—with Node-tested output.
Understanding Docker Vs Containerd
Container execution is handled by containerd. You can think of it as a container supervisor that handles container lifecycle operations.
Top 5 Best Practices for Containerized Deployments
Even though containers are valuable in the current software development trends, realizing containerized deployments in organizations is not easy. This article
7 tools to detect Memory Leaks with Examples
How to detect, capture and monitor memory leak in various applications such as C, C++ or in Linux process. use valgrind, core dump to capture leak information
How to limit CPU using cgroups (v2 and v1) on Linux
How to cap CPU with Linux cgroups: cgroup v2 cpu.max and cpu.stat, cgroup v1 cfs quota files, systemd CPUQuota and CPUWeight, shared limits with systemd slices, optional CPUQuotaPeriodSec, plus how this differs from …
How to Check Memory Usage per Process in Linux
Learn how to check memory usage by process in Linux with tested ps, top, pmap, /proc, smaps_rollup, statm, free, and pidstat examples. Understand RSS, VSZ, PSS, USS, shared memory, and how to find the top …
Linux memory limits in containers (cgroups, Docker, Kubernetes)
Learn how Linux enforces memory limits inside containers using cgroups, how cgroup v1 and v2 differ, why tools disagree, and how Docker and Kubernetes map limits to the kernel.
Debugging Kubernetes Operators: kubectl, Logs, and Webhook Failures
Learn how to debug Kubernetes Operators from the outside in: manager logs and flags, kubectl describe and events, stuck Terminating resources, validating and mutating webhooks (TLS, caBundle, cert-manager), conversion …
Check if a key exists in a JavaScript object: 7 reliable patterns
Check if key exists in object JavaScript: Object.hasOwn, in, hasOwnProperty, Object.keys, getOwnPropertyNames, symbols, Reflect.ownKeys—with example console output and own vs inherited rules.
Kubernetes Operator Tutorial - Build Production-Ready Operators
Free Kubernetes Operator course with hands-on lessons from core concepts through production Go, Helm, and hybrid operators—plus observability, security, CI/CD, and OLM packaging. Built on controller-runtime, Kubebuilder, …

