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.
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.
Difference Between := and = in Go
Learn the difference between := and = in Go, when to declare versus assign variables, and common mistakes beginners make.
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 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 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.
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.
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.
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.
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.
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.
Page 1 of 4 - 62 questions