Blog

Latest Articles - Page 61

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

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 Prasad4 min read
programming

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 …

Deepak Prasad4 min read
programming

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 …

Tuan Nguyen5 min read
programming

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 …

Tuan Nguyen5 min read
programming

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 …

Deepak Prasad6 min read
programming

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 …

Deepak Prasad5 min read
programming

Golang mutex: sync.Mutex lock and unlock with examples

Mutex in golang with sync.Mutex: Lock and Unlock, fix data races with go run -race, golang mutex lock patterns, defer unlock, sync.RWMutex for many readers, embed a mutex in a struct.

Antony Shikubu5 min read
programming

Golang global variables: package scope, exports, structs, and pitfalls

Golang global variable and golang global variables: package-level var, global variable declaration golang, golang globals and go global variables, golang global variables across packages with exported names, global …

Antony Shikubu6 min read
programming

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 …

Deepak Prasad4 min read
programming

Gorilla mux in Go: routing, path variables, subrouters, and middleware

Gorilla mux tutorial for gorilla mux and golang gorilla mux: install github.com/gorilla/mux, gorilla mux example with Methods and path vars, subrouters, middleware with r.Use, mux gorilla naming, and gorilla mux vs gin …

Antony Shikubu3 min read
programming

Go comma ok idiom: map, type assertion, and channel receive

Golang comma ok idiom and go comma ok idiom: the second bool from v, ok := m[k], v, ok := x.(T), or v, ok := <-ch; comma ok idiom golang covers maps, type assertions, and closed channels—not the same as if err != nil.

Antony Shikubu4 min read
programming

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.

Deepak Prasad6 min read
programming

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.

Deepak Prasad4 min read
programming

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.

Deepak Prasad5 min read
programming

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.

Tuan Nguyen5 min read
programming

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.

Deepak Prasad4 min read
programming

Change the Default log Package Prefix, Flags, and Output in Go

Go import log for the standard logger: change golang log format with SetFlags, add a golang log prefix with SetPrefix or log.New, use log.Printf for formatted lines, and send output to files or MultiWriter for console …

Antony Shikubu5 min read
programming

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.

Tuan Nguyen4 min read
programming

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.

Deepak Prasad3 min read
programming

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.

Tuan Nguyen5 min read
programming

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.

Tuan Nguyen9 min read
programming

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.

Tuan Nguyen6 min read
programming

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.

Tuan Nguyen9 min read
programming

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 …

Deepak Prasad7 min read
programming

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.

Tuan Nguyen4 min read
programming

JavaScript splice(): Add, Remove, and Replace Array Elements

Learn JavaScript splice() with examples to remove, add, and replace array elements, understand mutation, return values, and slice vs splice.

Olorunfemi Akinlua2 min read
programming

Replace Substring in JavaScript with replace() and replaceAll()

Replace substrings in JavaScript with replace(), replaceAll(), regex, and replacement functions—first match, all matches, and capture groups.

Olorunfemi Akinlua3 min read
programming

Remove Last Character from String in JavaScript

Learn how to remove the last character from a string in JavaScript using slice(), substring(), replace(), and Unicode-safe Array.from() examples.

Olorunfemi Akinlua3 min read
programming

JavaScript Open New Tab with window.open()

Learn how to open a new tab in JavaScript with window.open(). See _blank examples, noopener and noreferrer, popup blocker rules, same-tab alternatives, and secure browser behavior.

Olorunfemi Akinlua3 min read
programming

JavaScript Merge Objects: Spread, Object.assign, and Deep Merge

Merge objects in JavaScript: spread, Object.assign, shallow vs deep copies, overwrite order, and when structuredClone fits.

Olorunfemi Akinlua3 min read