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

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
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 Nguyen3 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 Nguyen4 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

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

Golang os.Stat: file metadata, FileInfo, and os.ErrNotExist

Golang os.stat and golang os stat: os.Stat returns fs.FileInfo (name, size, mode, mod time, IsDir); *File.Stat; errors.Is(err, os.ErrNotExist); os.Lstat vs Stat; PathError. Related os package file I/O.

Tuan Nguyen3 min read
programming

Golang json omitempty: meaning, zero values, and nested structs

Golang json omitempty and omitempty meaning in encoding/json; golang omitempty with strings, numbers, pointers; why omitempty has no effect omitting nested struct value fields; use pointers for optional objects; go json …

Tuan Nguyen4 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 Nguyen3 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 Nguyen3 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 Nguyen4 min read
programming

Golang os package: Open, Create, WriteFile, and *os.File

Golang os package for files: golang os open and OpenFile, os create golang with os.Create, os writefile golang with os.WriteFile, *os.File reads and append, Stat and errors.Is(os.ErrNotExist), Remove.

Tuan Nguyen4 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 Nguyen3 min read
programming

Golang for loop and `for range`: slices, maps, structs, interfaces, channels

Golang for loop and go for loop guide: for loop in golang syntax, golang for cycle with three-part and while-style loops, for range over slices, maps, strings, golang iterate struct fields with reflect, golang iterate …

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

Use Go as a Redis Client (go-redis, Ping, Get, Set, Hashes)

Connect a Go program to Redis with github.com/redis/go-redis/v9, Ping with context, Set and Get strings, and store hashes; run Redis locally and match password and DB settings.

Antony Shikubu2 min read
programming

Get Current Time in Milliseconds in Go (UnixMilli and Alternatives)

Convert time.Time to Unix milliseconds with UnixMilli, derive ms from UnixNano, or use Duration.Milliseconds after Sub; know int64 range limits from the time package docs.

Tuan Nguyen2 min read
programming

Golang io.ReadCloser: Reader+Closer, NopCloser, and read to string

io.ReadCloser golang and golang readcloser: embed io.Reader and io.Closer, io.NopCloser / nopcloser for Readers without real Close, golang io reader examples, and io.readcloser to string with io.ReadAll plus defer Close.

Tuan Nguyen3 min read
programming

Golang gRPC tutorial: server, client, and Protocol Buffers example

Golang grpc example and grpc golang tutorial: proto3 service, golang grpc server and grpc server golang with Register and Serve, go grpc client and go grpc example with grpc.NewClient and transport credentials, grpc go …

Antony Shikubu4 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 int to int64 and int64 to int conversion

Golang int to int64 and golang convert int to int64 with T conversions; golang int64 to int and int64 to int golang narrowing; go int to int64; golang cast int to int64; strconv round trip; portability when int is 32 …

Tuan Nguyen3 min read
programming

Convert float64 to int or int64 in Go (cast, round, strconv)

Golang float64 to int and golang float64 to int64: convert with int()/int64() truncation, math.Round for nearest integer, golang convert float to int and golang convert float64 to int safely, plus float64 to int golang …

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

FlashDB in Go: in-memory key-value store with optional persistence

FlashDB golang tutorial: an in memory database golang option and golang key value store with Redis-style types. Covers go in memory database setup, transactions, string SET/GET/DELETE, disk vs pure memory, and links for …

Tuan Nguyen4 min read
programming

Golang nil checks: pointers, interfaces, slices, and empty structs

Golang check if nil for pointers and maps; golang null pointer with == nil; check if slice is empty golang (len vs nil); golang check if struct is empty (not nil—reflect.IsZero); golang check if interface is nil …

Tuan Nguyen5 min read
programming

Go HTTPS Client: Skip TLS Verify (InsecureSkipVerify) and Safer Options

Use tls.Config InsecureSkipVerify on a dedicated net/http Transport for golang http client skip tls verify only in dev; prefer fixing golang ssl certificate trust with RootCAs instead of golang disable ssl verification …

Tuan Nguyen4 min read