Skip to content

Instantly share code, notes, and snippets.

@oktalz
Last active October 23, 2018 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oktalz/f04f36a3c2f61af22c7a6e06095d18eb to your computer and use it in GitHub Desktop.
Save oktalz/f04f36a3c2f61af22c7a6e06095d18eb to your computer and use it in GitHub Desktop.
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