Questions

Go questions

Choose a question page, learn the concept, then test your understanding with a quiz.

Decode HTTP JSON Responses in Go with json.Unmarshal

Learn how to fetch an HTTP response in Go, read its JSON body, match structs to JSON arrays and objects, and handle decoding errors correctly.

gojson

Default Function Parameter Values in Go

Learn how Go handles default function parameter values, why they are not supported, and practical patterns to achieve similar behavior.

godefault-valuefunction-calldefault-arguments

Deleting Keys from a Map During range in Go

Learn whether it is safe to delete map keys during a range loop in Go, how map iteration works, and common patterns for removal.

godictionaryfor-loop

Difference Between := and = in Go

Learn the difference between := and = in Go, when to declare versus assign variables, and common mistakes beginners make.

go

Does Go Provide a REPL? Understanding Interactive Go Development

Learn whether Go has a REPL, how interactive Go development works, and what tools beginners can use to test Go code quickly.

goread-eval-print-loop

Dynamic JSON Fields in Go: Hiding Struct Fields in API Responses

Learn how to return selected JSON fields from Go structs using maps, custom response types, and dynamic field filtering in APIs.

gojson

Efficient String Concatenation in Go: strings.Builder, bytes.Buffer, and Best Practices

Learn how to concatenate strings efficiently in Go using strings.Builder and bytes.Buffer, with examples and common pitfalls.

gostringstring-concatenation

Fix Go "Cannot Find Package" Errors: GOPATH and Package Layout

Learn why Go cannot find a package despite GOPATH being set, how GOPATH/src import paths work, and how modern Go modules solve imports.

gobuildpackage

Fix “Package Is Not in GOROOT” Errors in Go Projects

Learn why Go reports “package is not in GOROOT” and how Go modules, import paths, GOPATH, and project layout resolve builds correctly.

go

Generate UUID Version 4 in Go: Random Bytes, Variant, and Version Bits

Learn how to generate valid UUID v4 values in Go, set version and variant bits, format UUID strings, and use trusted libraries safely.

gouuid

Get Linux Process Details from a PID in Go

Learn how to inspect Linux process details from a PID in Go using procfs, including name, command line, status, owner, and safe error handling.

go

Go Bitwise Shift Operators: Understanding << and >>

Learn how << and >> work in Go with simple examples, bit-level intuition, common mistakes, and practical use cases.

gobitwise-operators

Go Channels: Is It OK to Leave a Channel Open Forever?

Learn when Go channels need to be closed, when leaving them open is safe, and how request-reply channel patterns work in Go.

gochannel

Go Constant Naming Conventions: Idiomatic const Names

Learn idiomatic Go constant naming conventions, including mixedCaps, exported names, grouped constants, iota, and common mistakes.

goconstantsnaming-conventions

Go Dot Imports: What a Period Means in an Import Statement

Learn what a dot import means in Go, how it exposes exported package names, why it is rare, and when to use it safely.

goimport

Go Equivalent of __dirname: Getting the Current File or Working Directory in Golang

Learn the Go equivalent of Node.js __dirname, when to use runtime.Caller, and how to get the current working directory idiomatically.

go

Go Filename Conventions: Naming Source Files and Structs

Learn Go filename conventions, when to use underscores, and why Go code is organized by responsibility rather than one struct per file.

gonaming-conventions

Go Indentation: Tabs, Spaces, and gofmt Formatting

Learn Go’s official indentation convention: how gofmt uses tabs for indentation and spaces for alignment in Go source code.

goformattingcoding-styleindentation

Go Interfaces vs Pointers to Interfaces: Why *Interface Is Usually Wrong

Learn why Go interface values already hold pointers, why *Interface causes assignment errors, and how to design interface-based APIs correctly.

gopointersinterface

Go Map Initialization: make vs Map Literal

Learn the difference between make(map[K]V) and map[K]V{} in Go, including nil maps, capacity hints, literals, and practical usage.

go

Page 2 of 9 - 162 questions