Blog

Latest Articles

Browse the latest tutorials, guides, and practical examples across Linux, DevOps, security, databases, and programming on GoLinuxCloud.

Explore the latest tutorials and guides across Linux, DevOps, programming, and more.

You can also browse content by category below:

  • Linux: Commands, administration, troubleshooting, and system operations
  • DevOps: CI/CD, Kubernetes, containers, and automation
  • Cloud: AWS, Azure, OpenStack, and hybrid cloud administration
  • Programming: Coding tutorials, scripting, and development concepts
  • Security: Ethical hacking, system security, and best practices
  • Databases: MySQL, MariaDB, PostgreSQL, and database management
  • Networking: Network setup, troubleshooting, and protocols
  • Storage: Disk management, file systems, and storage solutions
  • Tools: Useful tools and utilities for productivity

2329 articles

Blog illustration with latest articles, tutorials, guides, and how-to content across Linux and DevOps topics
programming

Golang random bool and random boolean: math/rand and crypto/rand

Golang random bool and golang random boolean with math/rand Intn and Float64, golang rand local source for tests, random boolean generator patterns in Go, and crypto/rand when you need unpredictable bits—not Python or …

Tuan Nguyen3 min read
programming

Delete keys from a map in Go with delete()

Remove entries from a map in Go with the built-in delete(map, key); deleting a missing key is safe; use the comma-ok form first when you want to log or branch on absent keys.

Tuan Nguyen2 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 print type: %T, reflect, and type switches

Go print type and golang print type of variable with fmt %T; golang get type via reflect.TypeOf and Kind; pointers, interface{}, and nil; type switches; golang print object as dynamic concrete type.

Tuan Nguyen3 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 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.

Tuan Nguyen3 min read
programming

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.

Tuan Nguyen3 min read
programming

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 …

Tuan Nguyen3 min read
programming

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.

Tuan Nguyen5 min read
programming

Go defer keyword: LIFO cleanup, evaluation rules, and loops

Use golang defer to schedule a function call when the surrounding function returns; arguments are evaluated immediately; multiple defers run in LIFO order; avoid defer in tight loops without an inner function.

Antony Shikubu3 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

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.

Tuan Nguyen3 min read
programming

Fix Go compiler errors: declared and not used, imported and not used

Fix declared and not used and imported and not used in Go: remove dead code, use the blank identifier for side-effect imports, and avoid := shadowing in branches so the outer variable is actually assigned.

Tuan Nguyen2 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

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 …

Tuan Nguyen4 min read
programming

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 …

Tuan Nguyen3 min read
programming

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.

Tuan Nguyen2 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

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 …

Tuan Nguyen3 min read
programming

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.

Tuan Nguyen4 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 map and map literal: basics, global maps, and iteration

Golang map and maps in golang: map[K]V, golang map literal and make, nil map panic, comma-ok lookup, delete and range, ordered iteration via sorted keys, golang global map and concurrency, dictionary analogy to Python.

Antony Shikubu4 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

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.

Tuan Nguyen9 min read
programming

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.

Tuan Nguyen7 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

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.

Tuan Nguyen6 min read
programming

Logrus for Go: golang logrus, levels, JSON, files, and hooks

Golang logrus and go logrus: install github.com/sirupsen/logrus, logrus log levels with SetLevel, TextFormatter and JSONFormatter, io.MultiWriter, SetReportCaller, hooks, and how long go.sum lines relate to the module …

Antony Shikubu5 min read