This is a workaround for golang/go#26460
The expected example output goes through some processing of whitespace that doesn't happen to the actual output. This is a tiny hack that processes the actual output correspondingly.
go get github.com/larschri/testable-example-output
Example:
package main
import (
"fmt"
"os"
testable "github.com/larschri/testable-example-output"
)
func ExampleCRLF() {
capture := testable.CaptureStdout()
fmt.Println("x\r\ny")
os.Stdout.Write(testable.Normalize(capture()))
// Output:
// x
// y
}
// Same as above, but with convenience function
func ExampleFixExampleOutput() {
done := testable.FixExampleOutput()
defer done()
fmt.Println("x\r\ny")
// Output:
// x
// y
}