Blog

Latest Articles - Page 59

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

3098 articles

Blog illustration with latest articles, tutorials, guides, and how-to content across Linux and DevOps topics
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 Nguyen6 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 Shikubu4 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 Prasad15 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

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 Prasad3 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 Nguyen4 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 Nguyen3 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 Prasad3 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 Nguyen4 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 Nguyen5 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 Prasad3 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 Prasad2 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 Prasad4 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 Shikubu5 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 Nguyen8 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 Nguyen7 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
programming

Golang log to file, stdout, and syslog with the standard log package

Golang log to file with os.OpenFile and log.SetOutput; golang log to file and stdout using io.MultiWriter; golang log syslog on Linux; go import log and golang log example; concurrency-safe default log.Logger.

Tuan Nguyen4 min read
programming

Go functions with multiple types: `any`, type switches, and generics

Golang function parameter multiple types: use any/interface{} with a type switch, golang function types with type parameters (generics), go function types and golang func type constraints, plus golang pass type as …

Tuan Nguyen5 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 Prasad8 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 Prasad5 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

Golang os exit, defer, and why deferred functions are not run

Golang os exit defer: os.Exit golang behavior matches pkg.go.dev os Exit — program terminates immediately and deferred functions are not run; patterns to run cleanup before exit, go os.exit deferred functions official …

Tuan Nguyen5 min read
programming

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 …

Tuan Nguyen4 min read
programming

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 …

Tuan Nguyen4 min read
programming

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 …

Tuan Nguyen5 min read
programming

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.

Tuan Nguyen4 min read