Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

New iferr snippets on 0.6.90-beta.9 #1962

Closed
uudashr opened this issue Oct 3, 2018 · 6 comments
Closed

New iferr snippets on 0.6.90-beta.9 #1962

uudashr opened this issue Oct 3, 2018 · 6 comments

Comments

@uudashr
Copy link
Contributor

uudashr commented Oct 3, 2018

vscode-go version: 0.6.90-beta.9

The new iferr snippet expand to:

if err != nil {
  return [nil, ]err
}

I'm not seeing this as generic cases. We are not always need return nil, err or return err which covered by the new snippet, but for testing purpose such as t.Error(err) need extra works. Is there a workaround to accommodate for such non-returning statement case. Since unit test are also important deliveries.

Give it a try, type below code using iferr snippet:

if err != nil {
  t.Error(err)
}
@ramya-rao-a
Copy link
Contributor

@uudashr Good point

cc @alecthomas who made the update.

@alecthomas We could revert the change to the iferr and create a new snippet for what you had in mind i.e returning nil, err or err

ramya-rao-a added a commit that referenced this issue Oct 3, 2018
@ramya-rao-a
Copy link
Contributor

I wanted to release the update today, so I have reverted the change to iferr and created a new snippet iferrret with the changes proposed by @alecthomas

We can continue the discussion here though.

@alecthomas
Copy link
Contributor

I just press the "select line" key combo and start typing in this situation. Another alternative would be to have a completion fragment cover the whole return, as well as the sub-parts.

But it's already been reverted so 🤷‍♂️

@ramya-rao-a
Copy link
Contributor

You mean like this:

if err != nil {\n\t${1:return} ${2:nil, err}\n}?

@uudashr
Copy link
Contributor Author

uudashr commented Oct 9, 2018

Got clue from @alecthomas
Might be like this if err != nil {\n\t${1:return ${2:nil, }${3:err}}\n}

@uudashr uudashr mentioned this issue Oct 9, 2018
@ramya-rao-a
Copy link
Contributor

This is fixed in the latest update to the Go extension (0.6.91)

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants