Skip to content

Adds snippet to check err before using res in GoNative#276

Merged
umeshp7 merged 8 commits intopostmanlabs:developfrom
someshkoli:fix/golangerrcheck
Oct 8, 2020
Merged

Adds snippet to check err before using res in GoNative#276
umeshp7 merged 8 commits intopostmanlabs:developfrom
someshkoli:fix/golangerrcheck

Conversation

@someshkoli
Copy link
Contributor

@someshkoli someshkoli commented Jun 1, 2020

Fixes: postmanlabs/postman-app-support#8318 partially
The err due to absence of err check is caused by go vet(kind of linting for go), which forces strict formatting, this includes checking for err being nil or not if we have assigned some value to err.
So basically if anyone uses go vet then err checking is mandatory if it has been assigned:
if err!=nil { //do something }

  • adds err check after client.Do(req)
  • adds println and return statement inside err condition body

 - adds err check after client.Do(req)
 - adds println and return statement inside err condition body
@abhijitkane
Copy link
Member

@someshkoli The original issue also mentions using http/https as a URL prefix. Also, can you update your comment to include the before/after snippet?

 - adds err check for ioutils.ReadAll method
 - removes unwanted console.log statements
@someshkoli
Copy link
Contributor Author

@someshkoli The original issue also mentions using http/https as a URL prefix. Also, can you update your comment to include the before/after snippet?

before:
image

after:
image

Also I was not sure about the http/https thing as that can also be done through the postmanapp so is a check required anyway ? Like we encounter error of invalid url in nodejs-request too when https/http is not provided in the url ?

someshkoli and others added 2 commits July 1, 2020 03:15
We should return from the function if an err is produced in all cases.
@umeshp7 umeshp7 merged commit 133f80a into postmanlabs:develop Oct 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bag with golang code generation

4 participants