Questions

Go questions

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

Go Pointers vs Values in Parameters and Return Values

Learn when to use structs, pointers, slices, and pointer receivers in Go parameters and return values with practical rules and examples.

gopointers

Go Ternary Operator Equivalent: Idiomatic Conditional Assignment in Go

Learn the idiomatic Go alternative to C's ternary operator and how to write clear conditional assignment with if statements.

goternary-operatorconditional-operator

Go Tests in Subdirectories: How Go Testing Works and Where Test Files Belong

Learn whether Go tests can live in subdirectories, why test files usually stay beside source files, and how package-based testing works.

gounit-testingbuild

Go Type Assertions: Converting interface{} to string Safely

Learn why interface{} cannot be used as a string directly in Go, and how to use type assertions safely with practical examples.

gotype-mismatch

Go Value Receiver vs Pointer Receiver: When to Use Each

Learn when to use value receivers vs pointer receivers in Go, including method semantics, performance, interfaces, and common mistakes.

gofunctionpointers

Go foreach Loop: How to Iterate with for range in Go

Learn how Go handles foreach-style iteration using for range to loop over slices, arrays, maps, strings, and channels.

goforeachslice

Go make() vs new(): When and Why to Use Each

Learn the difference between Go's make() and new(), when to use each, and why local variables can still be safely returned.

go

Handle SIGINT and Cleanup on Ctrl+C in Go

Learn how to capture Ctrl+C (SIGINT) in Go and run cleanup logic like deferred shutdown tasks before your program exits.

gosignalssigterm

How Go Fetches Private GitHub Repositories and Fixes "terminal prompts disabled"

Learn why `go get` fails on private GitHub repos with "terminal prompts disabled" and how to configure Go and Git correctly.

gogit

How Go Updates Third-Party Packages: Understanding go get, Modules, and Versioning

Learn how Go manages third-party package updates with go get, modules, and versioning, including how dependencies are stored and updated.

go

How break Works Inside switch in Go

Learn whether break exits a switch or a loop in Go, with examples of switch, select, labels, and common control-flow mistakes.

goselectswitch-statementbreak

How to Add Methods to Existing Types in Go

Learn why Go prevents adding methods to non-local types and how to extend existing types using wrapper types and helper functions.

goextension-methods

How to Assign a String to a Byte Array in Go

Learn how to copy a string into a fixed-size byte array in Go, with examples, pitfalls, and practical patterns for safe conversion.

go

How to Check If a File Exists in Go

Learn the idiomatic way to check whether a file exists in Go using os.Stat, errors.Is, and proper error handling patterns.

gofilestandard-library

How to Check Whether a Slice Contains a Value in Go

Learn how to check if a slice contains a value in Go, when linear search is required, and when to use maps instead of slices.

goslice

How to Check Whether a String Contains a Substring in Go

Learn how to test whether a string contains a substring in Go using strings.Contains with clear examples and common mistakes.

gosubstring

How to Check for an Empty String in Go

Learn the idiomatic way to test empty and non-empty strings in Go, with examples, comparisons, mistakes, and practical usage.

gostringis-empty

How to Check if a Map Contains a Key in Go

Learn how to test whether a key exists in a Go map using the idiomatic comma-ok pattern, with examples and common mistakes.

godictionarygo-map

How to Compare Structs, Slices, and Maps for Equality in Go

Learn how equality works for structs, slices, and maps in Go, including why `==` fails and when to use `reflect.DeepEqual`.

gogo-reflect

How to Compare Two Slices for Equality in Go

Learn how to check whether two slices are equal in Go, why == does not work, and how to compare slice contents safely.

gocomparisonslice

Page 2 of 6 - 112 questions