Questions
Go questions
Choose a question page, learn the concept, then test your understanding with a quiz.
How to Use go get with Private Repositories in Go
Learn the proper way to use go get with private Git repositories in Go, including SSH setup, GOPRIVATE, and common mistakes.
How to Write Multiline Strings in Go
Learn how multiline strings work in Go using raw string literals and escaped strings, with examples, pitfalls, and practical use cases.
Idiomatic Enums in Go: Representing Fixed Values Like DNA Bases
Learn the idiomatic way to represent enums in Go using typed constants and iota, with examples for DNA bases like A, C, T, and G.
Import Local Packages Without GOPATH in Go Using Modules
Learn how to organize and import local Go packages with Go modules, module paths, internal packages, and separate command directories.
Import Packages with the Same Name in Go Using Aliases
Learn how to import Go packages with the same package name using aliases, including safe examples with html/template and text/template.
Initialize Nested Structs in Go
Learn how to initialize nested and anonymous structs in Go with struct literals, named types, practical examples, and common mistakes.
Iterate Through Struct Fields in Go with Reflection
Learn how to iterate through Go struct fields using reflection, handle exported fields safely, and choose slices or maps when iteration matters.
List Standard Library Packages in Go
Learn how to list Go standard library packages with go list std and identify whether import paths belong to the installed Go distribution.
Lowercase JSON Key Names with json.Marshal in Go
Learn how to produce lowercase JSON keys in Go using struct tags, custom marshaling, and practical patterns with encoding/json.
Maximum Value of uint in Go: Finding Min and Max Safely
Learn how to get the maximum uint value in Go and use it safely when computing min and max values in loops.
Mock HTTP Dependencies in Go with Dependency Injection
Learn how to test Go code without real HTTP calls by injecting dependencies, using interfaces, and creating reliable fake HTTP clients.
Modifying Slice Elements While Ranging in Go
Learn why Go range values are copies and how to safely modify slice structs using indices, element pointers, and efficient loop patterns.
Nil Detection for Structs and Pointers in Go
Learn why Go struct values cannot be nil, how nil works with pointers and interfaces, and reliable ways to check Config values safely.
Optional Parameters in Go: How to Handle Missing Arguments
Learn how Go handles optional parameters, why function overloading is not supported, and common patterns to simulate optional arguments.
Pairs and Tuples in Go: Structs, Multiple Returns, and Channels
Learn how Go represents pair-like data with structs, why multiple return values are not tuples, and how to send paired values through channels.
Passing Functions as Parameters in Go
Learn how to pass functions as parameters in Go, use callbacks, and understand function types with clear examples and common mistakes.
Read an io.Reader into a String in Go
Learn how to read an io.Reader or HTTP response body into a string in Go, handle errors, close resources, and avoid unnecessary memory use.
Repeating Tasks at Intervals in Go with time.Ticker and Timers
Learn how to run repetitive tasks at intervals in Go using time.Ticker, timers, goroutines, and clean stop patterns.
Set HTTP Request Timeouts in Go with http.Client
Learn how to set reliable HTTP request timeouts in Go using http.Client and context, handle timeout errors, and close response bodies safely.
Split Strings on Whitespace in Go with strings.Fields
Learn how to split a Go string on repeated spaces, tabs, newlines, and Unicode whitespace using strings.Fields with practical examples.