Questions
Go questions
Choose a question page, learn the concept, then test your understanding with a quiz.
Blank Identifier Imports in Go: What `_` Means in an Import Statement
Learn what `_` means in a Go import, why blank identifier imports run package init code, and when to use them safely.
Calling Functions Across Files in the Same Go Package
Learn how Go uses packages across multiple files, why functions may appear undefined, and how to organize code correctly.
Check if a Value Exists in a Slice in Go
Learn how to check whether a value exists in a slice in Go, and why Go has no Python-style `in` operator for arrays or slices.
Concatenating Slices in Go with append
Learn how to concatenate two slices in Go using append and the ... operator, with examples, pitfalls, and practical usage.
Constructors in Go: Best Practice for Struct Initialization
Learn how to initialize structs with default values in Go using constructor-style functions, zero values, and idiomatic patterns.
Convert String to Integer in Go: Idiomatic Parsing with strconv.Atoi
Learn the idiomatic way to convert a string to an int in Go using strconv.Atoi, with examples, errors, and common mistakes.
Convert a Byte Slice to io.Reader in Go
Learn how to convert a byte slice to io.Reader in Go using bytes.NewReader and bytes.NewBuffer with clear examples and pitfalls.
Convert a Zero-Terminated Byte Array to String in Go
Learn how to convert a zero-terminated byte array to a Go string by trimming trailing null bytes safely and clearly.
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.
Difference Between := and = in Go
Learn the difference between := and = in Go, when to declare versus assign variables, and common mistakes beginners make.
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.
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.
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.
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.
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 Method Receiver Syntax Explained: Parentheses Before a Function Name
Learn what `(h handler)` and `(s *GracefulServer)` mean in Go function declarations and how method receivers work.
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.
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.
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.
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.
Page 1 of 5 - 92 questions