Questions
Go questions
Choose a question page, learn the concept, then test your understanding with a quiz.
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.
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.
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.
How to Convert an int to a String in Go
Learn how to convert an int to a string in Go using strconv.Itoa and FormatInt, and why string(i) gives a character instead of digits.
How to Delete a Key from a Map in Go
Learn how to remove entries from a Go map using delete(), with examples, common mistakes, and practical map usage patterns.
How to Delete an Element from a Slice in Go
Learn how to delete an element from a slice in Go using append, slicing, and index checks with simple examples and common mistakes.
How to Find the Type of an Object in Go
Learn how to inspect variable types in Go using reflect.TypeOf, %T, and type assertions with clear examples for beginners.
How to Format a String in Go Without Printing
Learn how to format and return strings in Go using fmt.Sprintf, with examples, comparisons, common mistakes, and a mini project.
How to Generate a Random String of Fixed Length in Go
Learn how to generate fixed-length random letter strings in Go using simple, fast, and beginner-friendly techniques.
How to Get a Slice of Map Keys in Go
Learn how to collect map keys into a slice in Go, why iteration is required, and common patterns for sorting and using keys safely.
How to Handle Configuration in Go
Learn practical ways to handle configuration in Go using flags, environment variables, and config files with clear examples and patterns.
How to Handle JSON POST Requests in Go
Learn the correct way to read and decode JSON POST request bodies in Go using net/http and encoding/json.
How to Handle Unused Variables and Imports in Go
Learn why Go reports unused variables and imports, how to fix them, and practical ways to work efficiently while developing Go code.
How to Initialize an Empty Slice in Go
Learn the correct way to initialize an empty slice in Go using make([]T, 0) or []T{}, with examples, differences, and best practices.
How to Iterate Over Map Keys in Go
Learn how to get and iterate over all keys in a Go map using range, with examples, common mistakes, and practical patterns.
How to Iterate Over a Range of Integers in Go
Learn how to loop over integer ranges in Go, why range does not work like Ruby, and practical patterns for counting with for loops.
How to List a Directory in Go
Learn how to list files and folders in a single directory in Go using os.ReadDir, with examples, common mistakes, and practical patterns.
How to Multiply time.Duration by an Integer in Go
Learn why multiplying rand.Int31n() by time.Millisecond fails in Go and how to correctly work with time.Duration values.
How to Pretty-Print JSON in Go
Learn how to pretty-print JSON in Go using json.MarshalIndent and json.Indent, with examples, mistakes, and practical usage.
How to Print Struct Variables in Go
Learn how to print struct fields in Go using fmt.Println, fmt.Printf, and formatting verbs with practical examples for beginners.