3 ms·
With named return values, the defer can modify them. For example: func Foo() (err error) { defer func() { err = errors.New("some error") }() } The
by amscanne 10y ago
With named return values, the defer can modify them. For example:
func Foo() (err error) {
defer func() {
err = errors.New("some error")
}()
}
The function will return the "some error" error.