Questions

Go questions

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

Go Method Overloading: Why SetOption Is Redeclared

Learn why Go does not support function or method overloading and how to design type-safe cgo wrappers for C varargs APIs.

gooverloading

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

Go Module Updates: go get -u vs go mod tidy

Learn why go get -u and go mod tidy produce different go.mod files, how Go module version selection works, and how to update safely.

gomodulepackagego-modules

Go Nil Pointer Dereference: Handle HTTP Errors Before Using Responses

Learn why Go HTTP code can panic on nil responses, how to check errors before defer, and how to safely handle API failures.

go

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 Slice Unpacking for Function Arguments

Learn how Go passes slice elements to variadic functions with ..., why fixed-parameter functions cannot unpack slices, and practical alternatives.

goargument-unpacking

Go Struct Tags: Use BSON and JSON Field Names Together

Learn how to define multiple Go struct tags for BSON and JSON so MongoDB documents and JSON responses use the correct field names.

gojsonstruct

Go Struct Tags: Using Backticks for JSON Field Names

Learn how Go struct tags use backticks to attach JSON metadata to fields, how encoding/json reads them, and when tags are not comments.

go

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

Go strings.HasPrefix and HasSuffix: Checking String Starts and Ends

Learn how Go checks string prefixes and suffixes with strings.HasPrefix and strings.HasSuffix, plus byte-slice alternatives and practical examples.

gostring

Go strings.HasPrefix: Check Whether a String Starts With a Prefix

Learn how to use Go's strings.HasPrefix to check whether a string begins with a prefix, with examples, mistakes, and a mini project.

gostringstartswith

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

Page 3 of 9 - 162 questions