Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time: quote original text in error returned by ParseDuration #38295

Closed
bruce-ricard opened this issue Apr 7, 2020 · 6 comments
Closed

time: quote original text in error returned by ParseDuration #38295

bruce-ricard opened this issue Apr 7, 2020 · 6 comments
Milestone

Comments

@bruce-ricard
Copy link

@bruce-ricard bruce-ricard commented Apr 7, 2020

I am trying to parse some time strings using the standard library. I am trying to parse the time "for breakfast" (literally).

What did you expect to see?

I would expect to see an error message explaining clearly what I did wrong.

What did you see instead?

time: invalid duration for breakfast

That's not very helpful.

time: invalid duration "for breakfast"

would be highly more useful for debugging.

Please think of using quotation marks for quoted text when writing natural language like English.

This part of the code in particular, contains quite a few occurrences of quoted text without quotation marks.

I am happy to submit a PR if you agree this is a good change.

@gopherbot gopherbot added this to the Proposal milestone Apr 7, 2020
@gopherbot gopherbot added the Proposal label Apr 7, 2020
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Apr 7, 2020

I see that time.Parse returns a time.ParseError which does quote the value, so, sure, we should do this. This doesn't need to be a proposal, so retitling.

@ianlancetaylor ianlancetaylor changed the title proposal: quote quoted text time: quote original text in error returned by ParseDuration Apr 7, 2020
@ianlancetaylor ianlancetaylor added NeedsFix and removed Proposal labels Apr 7, 2020
@ianlancetaylor ianlancetaylor modified the milestones: Proposal, Backlog Apr 7, 2020
@obeyda
Copy link
Contributor

@obeyda obeyda commented Apr 9, 2020

hi, I would like to help, can i work on this?

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Apr 10, 2020

@obeyda Thanks for offering. In this case it seems like @bruce-ricard is already planning to send in a change, according to the initial bug submission.

@bruce-ricard
Copy link
Author

@bruce-ricard bruce-ricard commented Apr 11, 2020

@obeyda if you want to help and work on it, go ahead. I can help you by reviewing your change if you want to. Let me know.

@obeyda
Copy link
Contributor

@obeyda obeyda commented Apr 11, 2020

@bruce-ricard sure thing, I'll start working on this and submit a CL.

@gopherbot
Copy link

@gopherbot gopherbot commented Apr 11, 2020

Change https://golang.org/cl/227878 mentions this issue: time: quote original values in returned errors

@gopherbot gopherbot closed this in 201cb04 Apr 14, 2020
sykesm added a commit to sykesm/fabric that referenced this issue Aug 18, 2020
time.ParseDuration now quotes the original value provided to the
function. This change modifies the assertion to handle the quotes when
present.

See golang/go#38295

Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
btl5037 added a commit to hyperledger/fabric that referenced this issue Aug 18, 2020
time.ParseDuration now quotes the original value provided to the
function. This change modifies the assertion to handle the quotes when
present.

See golang/go#38295

Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
Semior001 added a commit to Semior001/timetype that referenced this issue Sep 20, 2020
added wrapper for external errors, come outside the module to detect them in tests despite its content (golang/go#38295)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.