https://go.dev/issue/26460

- sean


On Mon, Dec 19, 2022 at 7:31 PM David M <david.m...@gmail.com> wrote:

> Not quite sure if this is a bug but it's annoying:
>
> If the example tested string contains a trailing space before a newline,
> the test always fails no matter how.
> // this test passes
> func ExampleFormat() {
>     fmt.Println("a\nb")
>     // Output:
>     // a
>     // b
> }
> // this test fails no matter we put "a" or "a " in the first output line.
> func ExampleFormat() {
>     fmt.Println("a \nb")
>     // Output:
>     // a
>     // b
>  }
>
> The doc <https://pkg.go.dev/testing#hdr-Examples> says "The comparison
> ignores leading and trailing space." I guess what's going on here is that
> it cut the trailing space in the desired output, but doesn't handle the
> space in the practical output if it's before a newline. Because the
> practical output may come from a 3rd party library, we have to respect how
> they print things.
>
> --
> 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/c24ffdb6-bde2-43be-b2ed-9735752bfb95n%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/c24ffdb6-bde2-43be-b2ed-9735752bfb95n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAGabyPobV%3DZZt2jV5yAjEkDffssnCZskrAFc1WG3%2BwvLV45tpw%40mail.gmail.com.

Reply via email to