Category

Programming Tutorials and Coding Guides

Explore programming tutorials with practical examples across multiple languages, scripting, and development concepts for beginners and advanced users.

Welcome to the Programming tutorials section, where you will learn coding concepts with real-world examples across multiple languages and platforms.

This category includes beginner to advanced guides covering scripting, automation, and application development in Java, JavaScript, Python, Go, TypeScript, and related stacks.

Whether you are learning programming for system administration or building applications, browse the articles below for practical examples and language-specific references.

Programming plays a crucial role in modern infrastructure and DevOps workflows. You can also explore DevOps and Linux to see how code integrates with system-level operations.

956 articles

Programming category illustration with code editor, automation, and debugging graphics
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 Shikubu4 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 Shikubu5 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 Prasad3 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 Shikubu3 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 Prasad5 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 Prasad4 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 Nguyen4 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 Shikubu4 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 Nguyen3 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 Nguyen4 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 Nguyen3 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
programming

Mediator Pattern in JavaScript: Practical JS Example

Mediator pattern in JavaScript: central coordinator, reduced coupling between components, when to prefer it over Observer, and a small runnable example.

Olorunfemi Akinlua3 min read
programming

JavaScript Observer pattern (EventTarget and custom pub/sub)

Implement the Observer pattern in JavaScript with EventTarget, callback lists, Pub/Sub differences, error handling, and avoiding listener leaks.

Olorunfemi Akinlua3 min read
programming

JavaScript Singleton Pattern with Class and Module Examples

Learn the JavaScript singleton pattern with class-based singleton, module singleton, getInstance examples, and when to avoid global state.

Olorunfemi Akinlua2 min read
programming

JavaScript Mouse Events: click, dblclick, mousedown, mouseup and mouseover

JavaScript mouse events: click, dblclick, mousedown, mouseup, mouseover, mouseenter, mouseout, mouseleave, mousemove, target, and coordinates—with Node-friendly snippets where possible.

Olorunfemi Akinlua3 min read
programming

JavaScript Remove Element from DOM with remove() and removeChild()

Learn how to remove DOM elements in JavaScript using element.remove(), parentNode.removeChild(), querySelector(), event handlers, and safe null checks.

Olorunfemi Akinlua3 min read
programming

JavaScript Replace DOM Element with replaceChild() and replaceWith()

Learn how to replace DOM elements in JavaScript using replaceChild(), replaceWith(), createElement(), text replacement, and safe element checks.

Olorunfemi Akinlua2 min read