Questions
Go questions
Choose a question page, learn the concept, then test your understanding with a quiz.
How to Print Boolean Values in Go
Learn how to print boolean values in Go using fmt format specifiers, including %t, Println, and practical examples for beginners.
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.
How to Print in Go Tests with the testing Package
Learn why output is hidden in Go tests and how to print debug information using fmt.Println, t.Log, and the -v flag.
How to Read Standard Input in Go
Learn how to read user input from the console in Go using bufio.Reader, fmt.Scanln, and common input-handling patterns.
How to Read a File Line by Line in Go
Learn how to read a file line by line in Go using bufio.Scanner and readers, with examples, pitfalls, and practical patterns.
How to Read an Entire File Into a String in Go
Learn how to read a whole file into a string in Go using standard library functions, with examples, pitfalls, and practical use cases.
How to Read an HTTP Response as a String in Go
Learn how to read an HTTP response body as a string in Go, convert []byte safely, and avoid common mistakes with net/http.
How to Read and Write Files in Go
Learn how to read from and write to files in Go with simple examples, file handles, byte slices, and common patterns for beginners.
How to Remove Packages Installed with go get in Go
Learn how go get installs packages, where files go, and how to remove previously downloaded Go packages safely and cleanly.
How to Run All Go Tests in a Project with go test
Learn how to run all tests in a Go project using go test across the current directory and all subdirectories.
How to Run Specific Go Tests: File vs Test Name in Go
Learn how to run specific Go tests using go test, -run, and package rules. Understand why Go targets packages, not test files.
How to Run a Go Program with Multiple Files in the Same Package
Learn how to split a Go main package across multiple files and run it correctly with go run, packages, and project structure basics.
How to Seed a Random Number Generator Properly in Go
Learn how to seed Go's random number generator correctly, avoid repeated values, and generate random strings efficiently.
How to Send JSON in a POST Request in Go
Learn how to send JSON in a POST request in Go, including dynamic JSON bodies, headers, marshaling, and common mistakes.
How to Set Default Values in Go Structs
Learn how default values work in Go structs, common patterns for custom defaults, constructors, and practical examples for clean Go code.
How to Set GOPATH on Ubuntu in Go
Learn what GOPATH is, where to set it on Ubuntu, which shell file to edit, and how it affects go get and Go projects.
How to Set Headers in an HTTP GET Request in Go
Learn how to set custom headers on an HTTP GET request in Go using net/http, with examples, mistakes to avoid, and practical patterns.
How to Sort a Slice of Structs by Field in Go
Learn the simplest ways to sort a slice of structs by a field in Go, including sort.Slice, custom comparisons, and common mistakes.
How to Trim Leading and Trailing Whitespace in Go Strings
Learn how to trim leading and trailing whitespace in Go using strings.TrimSpace, with examples, mistakes, and real-world use cases.
How to Use a Specific Git Commit in go.mod for a Go Module Dependency
Learn how to point a Go module dependency to a specific commit in go.mod using pseudo-versions, go get, and replace directives.