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

     1  # Tests that crlf in the output of examples are handled.
     2  # Verifies golang.org/issue/51269
     3  go test x_test.go
     4  
     5  -- x_test.go --
     6  package  x
     7  
     8  import (
     9      "io"
    10      "fmt"
    11      "os"
    12      "runtime"
    13  )
    14  
    15  func Example_lf() {
    16  	fmt.Print("foo", "\n", "bar")
    17  	// Output:
    18  	// foo
    19  	// bar
    20  }
    21  
    22  func Example_println() {
    23  	fmt.Println("foo")
    24  	fmt.Println("bar")
    25  	// Output:
    26  	// foo
    27  	// bar
    28  }
    29  
    30  func 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  }
    40  

View as plain text