Parameters and results
Functions declare their inputs and outputs:
func greet(name string) string {
return "Hello, " + name
}
Parameters flow in one way; results flow back. Go is call-by-value: functions receive copies, so mutating a parameter does not change the caller's variable.
Error handling pattern
The (value, error) idiom is everywhere in Go:
result, err := doThing()
if err != nil {
fmt.Println("failed:", err)
return
}
// use result
Functions return nil for the error when they succeed. Callers decide what to do with it instead of catching exceptions.