Ignoring Return Values
In Go, every declared variable must be used, otherwise the compiler will return an error. If a function returns multiple values and you only need some of them, you must explicitly ignore the others.
The Blank Identifier (_)
The underscore _ is a special “blank identifier” that tells the compiler to discard a value.
func getPoint() (x, y int) {
return 3, 4
}
// We only care about x, so we ignore y
x, _ := getPoint()
Why ignore?
Ignoring values is common when a function returns metadata or errors that aren’t relevant to your specific logic. It keeps your code clean and avoids “unused variable” errors.