Skip to content

Instantly share code, notes, and snippets.

@oktalz
Last active Oct 23, 2018
Embed
What would you like to do?
Comment for new go error handling feature

Comment on Go2ErrorHandlingFeedback

I like draft design

handle err {
    return fmt.Errorf("copy %s %s: %v", src, dst, err)
}

r := check some_func()

But to be more in sync with current handling of errors I would propose a diferent syntax

handle err {
    return fmt.Errorf("copy %s %s: %v", src, dst, err)
}

r , # :=  some_func()

that way, we would have three options

r , err :=  some_func()
r , _ :=  some_func() // yes yes,don't do that, but that can be done
r , # :=  some_func()

And you can pick in same way all three options depending on your needs.

Also you avoid new keyword check and part after := / = remains the same. It seems more readable to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment