diff options
| author | Obeyda Djeffal <djefobey@gmail.com> | 2020-04-11 23:21:22 +0100 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2020-04-14 00:01:14 +0000 |
| commit | 201cb046b745f8bb00e3d382290190c74ba7b7e1 (patch) | |
| tree | eb4e97572b16f5c526e5aaea09eadccfe0b1925d /src/time/example_test.go | |
| parent | 5a706d163d332ec3a83e38849efbaf550a9da7ab (diff) | |
| download | go-201cb046b745f8bb00e3d382290190c74ba7b7e1.tar.xz | |
time: quote original value in errors returned by ParseDuration
Quote original values passed as substring of ParseError.Message.
Improves the user experience of ParseDuration by making it
quote its original argument, for example:
_, err := time.ParseDuration("for breakfast")
will now produce an error, which when printed out is:
time: invalid duration "for breakfast"
instead of:
time: invalid duration for breakfast
Adapt test cases for format.Parse and format.ParseDuration.
Fixes #38295
Change-Id: Ife322c8f3c859e1e4e8dd546d4cf0d519b4bfa81
Reviewed-on: https://go-review.googlesource.com/c/go/+/227878
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/time/example_test.go')
| -rw-r--r-- | src/time/example_test.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/time/example_test.go b/src/time/example_test.go index f272ee44df..15811a62d3 100644 --- a/src/time/example_test.go +++ b/src/time/example_test.go @@ -379,7 +379,7 @@ func ExampleParse() { // 2013-02-03 00:00:00 +0000 UTC // 2006-01-02 15:04:05 +0000 UTC // 2006-01-02 15:04:05 +0700 +0700 - // error parsing time "2006-01-02T15:04:05Z07:00": extra text: 07:00 + // error parsing time "2006-01-02T15:04:05Z07:00": extra text: "07:00" } func ExampleParseInLocation() { |
