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
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@bruce-ricard
Copy link

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
@ianlancetaylor
Copy link
Contributor

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 The path to resolution is known, but the work has not been done. and removed Proposal labels Apr 7, 2020
@ianlancetaylor ianlancetaylor modified the milestones: Proposal, Backlog Apr 7, 2020
@obeyda
Copy link
Contributor

obeyda commented Apr 9, 2020

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

@ianlancetaylor
Copy link
Contributor

@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

@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 commented Apr 11, 2020

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

@gopherbot
Copy link

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

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>
lindluni pushed 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)
@golang golang locked and limited conversation to collaborators Apr 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants