On Wed, Nov 9, 2022 at 8:33 AM Erez Rokah <e...@cloudquery.io> wrote:
>
> I'm not sure if this is a bug or not. The following test will print both 
> error messages:
>
> ```
> func TestTimeStringParse(t *testing.T) {
>   for i := 0; i < 100000; i++ {
>     timeString := time.Now().Add(time.Duration(rand.Int63())).String()
>     _, err := time.Parse(defaultStringFormat, timeString)
>    if err == nil {
>      t.Errorf("time.Parse(%q) should return error", timeString)
>     } else {
>       t.Errorf("time.Parse(%q) should not return error", timeString)
>     }
>   }
> }
> ```
>
> The failure stems from Go 1.19 adding the extra text `m=+<int>` for the 
> monotonic clock.
> This doesn't happen for every `time.String()` invocation, which is a bit 
> confusing.
> I understand one shouldn't try to parse `time.String()`, especially with the 
> private format, however this does looks like something that worked before Go 
> 1.19.
>
> Would be glad to know what others think.


What is defaultStringFormat?

Adding m=<int> is not new in Go 1.19.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcWip6K-WYbwoYKwisEDJ0m9_W92V-UFsRiuQweA9K_sQg%40mail.gmail.com.

Reply via email to