programming

Golang SHA-256: Hash Strings, Files, and Verify Checksums

Use Go crypto/sha256 to hash strings and files, format SHA-256 as hexadecimal, stream large files with io.Copy, and verify known checksums.

Tuan Nguyen8 min read
programming

Golang byte to int: Convert `byte` and `[]byte` Correctly

Convert byte and []byte to integers in Go using int, strconv.Atoi, encoding/binary, varints, and big.Int, with byte order and error handling explained.

Tuan Nguyen6 min read
programming

Golang JSON `omitempty`: Zero Values, `omitzero`, and Nested Structs

Learn how Go JSON omitempty works for zero values, pointers, slices and nested structs, how omitzero differs, and what changes with encoding/json/v2 in Go 1.27.

Tuan Nguyen8 min read
programming

Golang For Loop and `for range`: Syntax and Examples

Learn Go for loops and for range with examples for counters, while-style loops, slices, maps, strings, integers, channels, break, continue, and modern iterators.

Antony Shikubu12 min read
programming

Convert float64 to int or int64 in Go

Convert float64 to int or int64 in Go using direct conversion or math.Round, RoundToEven, Floor and Ceil, with overflow, NaN and Inf handling.

Tuan Nguyen6 min read
programming

How to Remove or Uninstall a Go Package

Learn how to remove a Go module dependency, undo go get, remove Go 1.24+ tool dependencies, uninstall go install binaries, and clear the module cache.

Tuan Nguyen10 min read
programming

Golang os.Stat: File Metadata, File Existence, and Lstat

Learn how to use os.Stat in Go to read file metadata, check whether a path exists, distinguish files and directories, handle errors, and compare Stat with Lstat.

Tuan Nguyen6 min read
programming

Go Gopher: History of the Golang Mascot

Learn who created the Go Gopher, how Renée French's WFMU character became Go's mascot in 2009, whether it has a name, and how the artwork is licensed.

Tuan Nguyen6 min read
programming

Golang Zap Logger: Structured Logging with Logger and SugaredLogger

Learn structured logging in Go with Uber Zap, including Logger vs SugaredLogger, production and development loggers, fields, levels, request IDs, and configuration.

Antony Shikubu7 min read
programming

Check if a String Contains a Substring in Go (`strings.Contains`)

Use strings.Contains to check whether a Go string contains a substring, including case-insensitive checks, multiple values, ContainsAny, ContainsRune, and common edge cases.

Deepak Prasad6 min read
programming

Golang Hide Password Input with x/term ReadPassword

Learn how to hide password input in Go using golang.org/x/term ReadPassword, detect terminals with IsTerminal, handle non-TTY input, and understand asterisk masking.

Deepak Prasad5 min read
programming

Fix "go.mod file not found in current directory or any parent directory"

Fix Go's "go.mod file not found in current directory or any parent directory" error for existing projects, new modules, go get, workspaces, IDEs, and CI.

Tuan Nguyen9 min read
programming

Golang os Package: Files, Directories, and Environment Examples

Learn the Go os package with practical examples for opening, creating and writing files, working with directories, file metadata, environment variables, and paths.

Tuan Nguyen10 min read
programming

Fix Go "declared and not used" and "imported and not used"

Fix Go's "declared and not used" and "imported and not used" compiler errors, including blank identifiers, unused return values, imports, and := shadowing.

Tuan Nguyen6 min read
programming

Golang WebSocket Examples: Server and Client

Learn how to build a WebSocket server and client in Go using Gorilla WebSocket, send text and JSON messages, close connections, and handle common errors.

Tuan Nguyen9 min read
programming

Golang Read YAML File: Parse YAML into Struct or Map

Learn how to read and parse YAML files in Go, unmarshal YAML into structs or maps, handle nested data and lists, and decode multiple YAML documents.

Tuan Nguyen9 min read
programming

Golang fsnotify: Watch File and Directory Changes in Go

Learn how to use fsnotify in Go to watch files and directories, handle file events, watch one file reliably, add recursive watches, and debounce changes.

Deepak Prasad8 min read
programming

Golang Cobra Tutorial: Subcommands, Flags, and CLI Examples

Golang Cobra tutorial with a complete go cobra example: install spf13/cobra, build subcommands, local and persistent flags, test with go run, set --version, and scaffold apps with cobra-cli.

Tuan Nguyen8 min read
programming

Hexagonal Architecture in Golang: Project Structure, Example & Best Practices

Hexagonal architecture in Go with a Gin messaging API, GORM v2 and Valkey adapters, folder layout, inbound and outbound ports, curl verification, and when ports-and-adapters beats layered CRUD.

Antony Shikubu13 min read
programming

HackerRank Solution: Python Lists [Basic Data Types]

This tutorial covers solutions for Python Lists question from Hacker Rank using if statements, map and len() method Using the split() function

Bashir Alam5 min read
programming

HackerRank Solution: Python Print Function

In this tutorial we cover different methods to solve python print function hackerrank solution

Bashir Alam4 min read
programming

Polymorphism in Java Explained [In-Depth Tutorial]

There are two types of polymorphism in Java: compile-time polymorphism and runtime polymorphism.

Bashir Alam9 min read
programming

Fix JavaScript Error: IPython is not defined in Jupyter

Fix IPython is not defined in Jupyter Notebook 7, JupyterLab, VS Code, and Colab by selecting the correct Matplotlib backend and kernel.

Olorunfemi Akinlua12 min read
programming

Compare Structs, Slices, and Maps in Go (Equality and Deep Equality)

Learn how to compare two structs, slices, and maps in Go: struct equality with ==, slice and map checks with slices.Equal and maps.Equal (Go 1.21+), reflect.DeepEqual, test-focused go-cmp, and when to write your own …

Tuan Nguyen7 min read
programming

Copy Structs in Go: Value Assignment, Pointers, Shallow vs Deep

Copy structs in Go: assignment copies the struct value; fields that are slices, maps, or pointers still alias shared backing data unless you duplicate them; primitives and arrays inside the struct copy by value.

Tuan Nguyen3 min read
programming

Golang UDP server and client: ListenPacket, DialUDP, and sending packets

Golang udp server and udp server golang with net.ListenPacket, golang udp client and go udp server patterns with DialUDP, golang send udp packet via WriteTo and Write, plus a minimal udp example for go udp and golang udp …

Tuan Nguyen5 min read
programming

Golang TCP server and client: step-by-step from basic to advanced

Step-by-step golang tcp server and golang tcp client: net.Listen and net.Dial, tcp server golang and tcp client golang patterns, deadlines and concurrent accepts with the net package.

Tuan Nguyen6 min read
programming

Java Type Casting Explained [Easy Examples]

The Java type casting is a method or process that converts a data type into another data type in both ways manually and automatically.

Bashir Alam8 min read
programming

Python shelve Module — Persistent Dict-Like Storage

Learn Python shelve for persistent dict-like storage: open(), read/write, access flags, writeback, sync(), thread safety limits, security, and when to use SQLite instead.

Deepak Prasad6 min read
programming

Python requests

Learn how to use Python requests for HTTPS GET and POST requests. Install requests with pip, check response.status_code, handle 200 responses, use raise_for_status(), set timeouts, and compare requests with urllib and …

Bashir Alam8 min read