Re: [go-nuts] the example always fails if the string contains a trailing space before a newline

2022-12-19 Thread 'Sean Liao' via golang-nuts
https://go.dev/issue/26460

- sean


On Mon, Dec 19, 2022 at 7:31 PM David M  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  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
> 
> .
>

-- 
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.


[go-nuts] the example always fails if the string contains a trailing space before a newline

2022-12-19 Thread David M
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  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.