time: Parse has no description of what errors it can generate #32820
Labels
Documentation
Issues describing a change to documentation.
help wanted
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
This is a comment on the current godoc at https://golang.org/pkg/time/. This godoc does not offer any description of what is or is not an error in parsing.
Some possible errors are pretty obvious - out of range elements, for example (day of year 400, month 13, etc.)
And I do think it's reasonable to expect that you'll get an error if the string doesn't match up very well with the layout you gave (two-digit year instead of four, mismatched punctuation, etc.). But for most packages we seem to be more thorough in explaining border-case errors.
For example, what if the input string has some trailing stuff after the part to be parsed? One could argue that this is a mismatch of the format, and should be an error, or that this is something that should be let slide because you might be parsing just the beginning of a string. Again, I would interpolate the former and expect the caller to do some massaging, but it seems unwise to not be explicit.
The text was updated successfully, but these errors were encountered: