Questions

Go questions

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

Are Go Maps Passed by Value or Reference?

Learn Go map parameter and return semantics: maps are passed by value, while copies share underlying data. Know when map pointers are useful.

go

Authentication for Go REST APIs: Sessions, Tokens, and Middleware

Learn practical authentication patterns for Go REST APIs, including password hashing, server sessions, bearer tokens, middleware, and security rules.

goauthentication

Automatic Build Versioning in Go: Embed Incrementing Build Numbers

Learn how to add automatic build versioning in Go using linker flags, build metadata, CI counters, and Git-based version values.

go

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.

goimport

Call Functions Between Go Files in the Same Package

Learn how to call a function from another Go file using packages, one main function, exports, and the correct go run command.

go

Calling C++ from Go with cgo and C Wrappers

Learn how Go calls C++ through cgo and a C-compatible wrapper, including opaque handles, memory ownership, build flags, and safe patterns.

gocppwrapper

Calling Functions Across Files in the Same Go Package

Learn how Go uses packages across multiple files, why functions may appear undefined, and how to organize code correctly.

goundefinedfunc

Can You Declare a Constant Map in Go? Understanding Constants and Maps in Golang

Learn why Go does not allow constant maps, and see practical alternatives using variables, immutability patterns, and safe access.

go

Check Whether a Go Struct Is Empty

Learn how to check whether a Go struct has its zero value, why struct comparisons need parentheses, and when to use explicit validation.

gostruct

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.

goif-statement

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.

goappendslicevariadic-functions

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.

gooopconstructor

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.

gostringtype-conversion

Convert a Byte Slice to a String in Go

Learn how to convert []byte to string in Go, when UTF-8 matters, and how to encode SHA-1 bytes safely as hexadecimal filenames.

gotypessha1

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.

go

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.

go

Copying Slices in Go: Why copy() Needs a Destination Length

Learn why Go's copy() does not grow slices, how slice length and capacity affect copying, and safe ways to duplicate slices.

goslice

Count Characters in a Go String: Bytes, Runes, and UTF-8

Learn how to count characters in Go strings correctly. Understand len bytes, UTF-8 runes, and grapheme clusters with practical examples.

gostringcharacterstring-length

Create a *int64 Value in Go: Pointers, Literals, and Addressability

Learn why Go cannot take the address of an int64 literal, how addressability works, and safe ways to initialize *int64 fields.

gopointersstructliterals

Creating 2D Slices in Go: Initialization, Layouts, and Patterns

Learn how to create 2D and multidimensional slices in Go, why loops are needed, and when to use nested or flat storage.

gomatrixmultidimensional-arrayslice

Page 1 of 9 - 162 questions

PreviousNext