Author

Deepak Prasad

Deepak Prasad

R&D Engineer

at · 1300 articles published

Founder of GoLinuxCloud with more than 15 years of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels across development, DevOps, networking, and security, delivering robust and efficient solutions for diverse projects.

Areas of expertise

Certifications & credentials

  • Red Hat Certified System Administrator in Red Hat OpenStackID: 180-246-001
  • Certified Kubernetes Application Developer (CKAD)
  • Red Hat Certified Specialist in Ansible Automation
  • Go: Data Structures, Algorithms and Design Patterns With Go
Author profile illustration for Deepak Prasad — technical writer at GoLinuxCloud

Articles by Deepak Prasad

programming

Golang Time Package: time.Now, Duration, Format, and Parse Examples

Use Go time package for time.Now, time.Duration, formatting and parsing, Add and Sub, Since and Until, comparing times, Sleep, Timer, and Ticker basics, plus common mistakes.

Deepak Prasad8 min read
programming

Golang background process: start, monitor, and wait with os/exec

Golang start process and spawn with os/exec Start Wait and Run; CommandContext timeouts; goroutines channels WaitGroup for golang background jobs; go run in background vs shell; wait golang patterns.

Deepak Prasad4 min read
programming

Golang Switch Case Statement: Examples, Multiple Cases, and Type Switch

Use the switch statement in Go for switch case and default, comma-separated cases, expressionless switch, initial statements, type switch on any, fallthrough, and patterns that replace long if-else chains.

Deepak Prasad9 min read
programming

Install Go on Ubuntu: apt, snap, or official tarball (with checksum)

Installing golang on Ubuntu: apt golang-go, snap install go --classic, official go.dev/dl tarball with sha256 verify, optional build-from-source with bootstrap Go, amd64 and arm64, PATH and GOBIN, go version, go mod init …

Deepak Prasad6 min read
programming

Golang get IP address: local IPv4/IPv6, hostname, and Linux interfaces

Golang get ip address and golang get local ip: net.InterfaceAddrs and Interfaces for linux get local ip, golang get hostname with LookupHost, go get ip address heuristics, golang get local ip address without loopback, …

Deepak Prasad3 min read
programming

Golang read password from stdin: x/term ReadPassword and TTY checks

Golang read password from stdin with golang.org/x/term ReadPassword: pkg.go.dev ReadPassword IsTerminal, example os.Stdin.Fd and syscall.Stdin on Linux, ReadPassword Windows and platforms, no echo vs golang asterisk …

Deepak Prasad3 min read
programming

Golang user input: Scan, Scanf, and bufio for stdin

How to take input in golang and golang get user input from stdin: fmt.Scan Scanln Scanf for typed tokens, golang read input with bufio; go read user input and how to get user input in go with line-based reads; input …

Deepak Prasad3 min read
programming

Golang panic and recover: defer, stack unwinding, and catch-style recovery

Golang panic and go panic: how unwinding works with defer; golang recover from panic and go recover panic in a deferred function (go catch panic / golang catch panic pattern); panic vs errors and os.Exit; logging with …

Deepak Prasad4 min read
programming

Golang garbage collection: GC, heap, GOGC, runtime.GC, and tuning

Golang garbage collection and golang gc: go garbage collector basics, heap in golang and HeapAlloc, golang force garbage collection with runtime.GC, GOGC and GOMEMLIMIT, gctrace, pprof, and garbage collection in go for …

Deepak Prasad14 min read
programming

Create Nested Directories in Go (os.Mkdir, os.MkdirAll, mkdir -p)

Create nested directories in Go with os.Mkdir per level, os.MkdirAll for a full path in one call, filepath.Join for portable paths, optional os.Stat guards, or exec.Command mkdir -p when shell semantics are acceptable.

Deepak Prasad2 min read
programming

Copy Files in Go While Preserving Permissions

Copy a file in Go with os.Open, io.Copy to os.Create, then os.Chmod from os.FileInfo.Mode; or use os.ReadFile and os.WriteFile with the source mode; os.Rename moves within a filesystem rather than copying.

Deepak Prasad2 min read
programming

Convert a Slice to a Map in Go (Set, Index Map, Group Duplicates)

Build a map from a slice in Go: use elements as keys for set-like maps, pick struct fields as keys, map indices to values, or map keys to slices of positions for duplicates.

Deepak Prasad2 min read
programming

Convert int to string in Go (strconv, fmt, bytes.Buffer)

Convert int to string in Go with strconv.Itoa or strconv.FormatInt, fmt.Sprintf or fmt.Fprintf to an io.Writer, and strings.Builder for custom assembly; compare with general type conversion in Go.

Deepak Prasad1 min read
programming

Go context Package: Cancel, Timeout, Deadlines, and Values

Use golang context for deadlines and cancellation: Background and TODO roots, WithCancel, WithTimeout, WithDeadline, and WithValue for request-scoped data; always call cancel and pass ctx as the first parameter.

Deepak Prasad3 min read
programming

Golang Shiny: windows, events, and drawing with x/exp/shiny

Experimental desktop GUIs with golang.org/x/exp/shiny: driver.Main, screen buffers, paint and lifecycle events from x/mobile, resize-safe drawing, and when to prefer Fyne, Gio, Ebiten, or Wails.

Deepak Prasad8 min read
programming

Go uint8 conversion: string to uint8, uint8 to string, and byte examples

Parse numeric strings into uint8 with strconv.ParseUint and bit size 8, convert uint8 to digit strings vs runes with FormatUint and string(), byte alias, string indexing, []uint8 slices, wider ParseUint sizes, RGB and …

Deepak Prasad8 min read
programming

Call a Function From Another Package or File in Go

Call Go code from another file or another package: what to import, when you do not need an import, capital letters for public functions, and how to fix typical errors.

Deepak Prasad7 min read
programming

go list installed packages: list Go packages, modules, and install paths

go list command for std, ./..., and all; go list -m all for modules; where Go stores packages (GOMODCACHE, GOROOT, GOPATH/bin); list go packages and binaries from go install without mistaking modules for a global package …

Deepak Prasad4 min read
programming

Golang Anonymous Function Explained with Examples

Learn anonymous functions in Go: function literals, immediate calls, parameters and return values, variables, callbacks, closures, goroutines, and common mistakes like loop capture.

Deepak Prasad7 min read
programming

Convert Go []byte to string (Casting, Builder, Buffer, strconv)

Convert go bytes to string with string(b), fmt.Sprintf, strings.Builder or bytes.Buffer, strconv for numbers, and know when copying happens for UTF-8 text and binary data.

Deepak Prasad2 min read
programming

Golang integer types: int, int32, int64, uint, and sizes

Golang int and go int types, golang int types and sizes, golang int vs int32, uint and sized integers, byte and rune aliases, and how golang data types size depends on int versus int8–int64.

Deepak Prasad4 min read
programming

Golang CPU affinity on Linux: sched_setaffinity, taskset, GOMAXPROCS

Golang CPU affinity on Linux: cpu masking with golang.org/x/sys/unix SchedSetaffinity, taskset from Go, runtime.LockOSThread for set thread affinity, and why gomaxprocs golang is not affinity.

Deepak Prasad4 min read
programming

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 …

Deepak Prasad3 min read
programming

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 …

Deepak Prasad3 min read
programming

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 …

Deepak Prasad3 min read
programming

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.

Deepak Prasad4 min read
programming

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+.

Deepak Prasad4 min read
programming

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 …

Deepak Prasad3 min read
programming

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 …

Deepak Prasad3 min read
programming

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.

Deepak Prasad16 min read