Questions

Go questions

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

Stack vs Heap Allocation in Go: Structs, Escape Analysis, and Garbage Collection

Learn how Go decides stack vs heap allocation for structs, why returning local addresses is safe, and how pointers relate to GC.

goheap-memorystack-memory

Struct Tags in Go: What They Are and How They’re Used

Learn what struct tags in Go are, how reflection reads them, and how packages like json, xml, db, and validation use them in real projects.

gostructreflectiontags

Subtract One Month from time.Time in Go with AddDate

Learn why Go time.Duration cannot represent a calendar month and how to subtract months safely from time.Time using AddDate.

godatetime

Test Setup in Go with TestMain and t.Cleanup

Learn how to perform global and per-test setup in Go using TestMain, helper functions, t.Cleanup, and table-driven tests.

gounit-testing

Trim Newlines From Strings in Go: ReadString and Substrings

Learn idiomatic Go string manipulation: remove ReadString newlines safely with strings.TrimSuffix, handle CRLF, and avoid unsafe slicing.

gosubstring

Understanding "does not implement interface" with Pointer Receivers in Go

Learn why Go shows "does not implement interface" with pointer receivers, how method sets work, and how to fix common interface errors.

gopointersmethodsinterface

Understanding ./... Package Patterns in Go Commands

Learn what the Go ./... package pattern means, how it recursively selects packages, and how to use it with go test, build, and list.

go

Understanding GOPATH and GOROOT in Go

Learn what GOPATH and GOROOT mean in Go, how they differ, and how to fix package not found errors during installation.

gogopath

Understanding Import Cycle Not Allowed in Go

Learn how to read and fix the Go "import cycle not allowed" error with clear examples, dependency tracing, and refactoring tips.

go

Understanding interface{} in Go: The Empty Interface

Learn what interface{} means in Go, how it stores values of any type, and how to safely use it with type assertions and type switches.

go

Understanding rune in Go: Characters, Unicode, and Case Swapping

Learn what a rune is in Go, how it differs from byte, and how rune comparisons work in case-swapping examples.

goterminologyrune

Understanding the "go.mod file not found" Error in Go Modules

Learn why Go shows "go.mod file not found" and how to fix it in Go 1.16+ using modules, go mod init, and proper project setup.

golinux

Using assert() in C and C++: Benefits, Risks, and Best Practices

Learn when to use assert() in C and C++, why assertions differ from error handling, and how to avoid side effects and release-build bugs.

gocppcerror-handling

What Does go install Do in Go? Build vs Install Explained

Learn how Go's go build and go install commands differ, where executables are placed, and how to choose a custom install location.

go

What Is the Zero Value of time.Time in Go?

Learn the zero value of time.Time in Go, why nil does not work, and how to check and use zero dates correctly in Go code.

gotimenull

When Does init() Run in Go? Package Initialization Explained

Learn exactly when Go's init() runs, how package variables are initialized, and what happens before main() starts.

goinit

Why Go Cannot Convert []T to []interface{} Implicitly

Learn why Go does not convert []T to []interface{} automatically, how slice memory differs, and the correct way to convert slices safely.

gogo-reflectgo-interface

Why Go Compiles So Quickly: Understanding Go Build Speed

Learn why Go compiles so fast, including language design, compiler choices, package caching, and how Go build speed compares to others.

goperformancebuildcompiler-construction

Why Go Does Not Have a Built-In Set Type: Understanding Sets with Maps in Go

Learn why Go has no built-in set type and how to implement sets using maps, with examples, trade-offs, and beginner-friendly guidance.

godata-structuresset

Why Go Struct to JSON Returns Empty Object {}: Exported Fields and json.Marshal

Learn why Go json.Marshal returns {} for structs with unexported fields, and how to fix it using exported field names and JSON tags.

gojson

Page 8 of 9 - 162 questions