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.

Reply via email to