Questions

Go questions

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

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.

go

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.

gopackage

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.

gorandom

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.

gojsonrestapiary.io

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.

gostructinitializationdefault-value

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.

golinuxubuntu

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.

gohttp

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.

gosorting

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.

go

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.

gogitmodule

How to Use go get with Private Repositories in Go

Learn the proper way to use go get with private Git repositories in Go, including SSH setup, GOPRIVATE, and common mistakes.

gogit

How to Write Multiline Strings in Go

Learn how multiline strings work in Go using raw string literals and escaped strings, with examples, pitfalls, and practical use cases.

gostringmultiline

Idiomatic Enums in Go: Representing Fixed Values Like DNA Bases

Learn the idiomatic way to represent enums in Go using typed constants and iota, with examples for DNA bases like A, C, T, and G.

goenumsgenetics

Lowercase JSON Key Names with json.Marshal in Go

Learn how to produce lowercase JSON keys in Go using struct tags, custom marshaling, and practical patterns with encoding/json.

gojsonserializationtags

Maximum Value of uint in Go: Finding Min and Max Safely

Learn how to get the maximum uint value in Go and use it safely when computing min and max values in loops.

gonumbers

Optional Parameters in Go: How to Handle Missing Arguments

Learn how Go handles optional parameters, why function overloading is not supported, and common patterns to simulate optional arguments.

gooverloading

Passing Functions as Parameters in Go

Learn how to pass functions as parameters in Go, use callbacks, and understand function types with clear examples and common mistakes.

gofunction

Repeating Tasks at Intervals in Go with time.Ticker and Timers

Learn how to run repetitive tasks at intervals in Go using time.Ticker, timers, goroutines, and clean stop patterns.

go

Stack vs Heap Allocation in Go: Structs, Escape Analysis, and Garbage Collection

Learn how Go decides stack vs heap allocation for structs, why returning local addresses is safe, and how pointers relate to GC.

goheap-memorystack-memory

Struct Tags in Go: What They Are and How They’re Used

Learn what struct tags in Go are, how reflection reads them, and how packages like json, xml, db, and validation use them in real projects.

gostructreflectiontags

Page 5 of 6 - 112 questions