...

Text file src/cmd/go/testdata/script/test_crlf_example.txt

Documentation: cmd/go/testdata/script

     1# Tests that crlf in the output of examples are handled.
     2# Verifies golang.org/issue/51269
     3go test x_test.go
     4
     5-- x_test.go --
     6package  x
     7
     8import (
     9    "io"
    10    "fmt"
    11    "os"
    12    "runtime"
    13)
    14
    15func Example_lf() {
    16	fmt.Print("foo", "\n", "bar")
    17	// Output:
    18	// foo
    19	// bar
    20}
    21
    22func Example_println() {
    23	fmt.Println("foo")
    24	fmt.Println("bar")
    25	// Output:
    26	// foo
    27	// bar
    28}
    29
    30func Example_crlf() {
    31	if runtime.GOOS == "windows" {
    32		io.WriteString(os.Stdout, "foo\r\nbar\r\n")
    33	} else {
    34		io.WriteString(os.Stdout, "foo\nbar\n")
    35	}
    36	// Output:
    37	// foo
    38	// bar
    39}

View as plain text