why does reading a file on windows add CRLF to unix line endings... sometimes?

100 views
Skip to first unread message

Dan Kortschak

unread,
Apr 22, 2019, 6:21:06 PM4/22/19
to golang-nuts
I have a test that is failing on travis on a windows build due to the
presence of CRLF in the bytes returned by ioutil.ReadFile. The file
itself uses unix line endings, so the CR is inserted by something
somewhere along the line.

However, this is not always the case. On AppVeyor, I do not see this;
it passes using the same tests that pass on travis with linux,
returning only LF new lines.

Is there some reason by file reading on one windows build will behave
differently to another?

thanks
Dan

Logs showing behaviour:

Test code:
```
package crlf

import (
   "bytes"
   "io/ioutil"
   "testing"

   "github.com/kortschak/utter"
)

func TestReadFile(t *testing.T) {
   b, err := ioutil.ReadFile("crlf_test.go")
   if err != nil {
      t.Errorf("unexpected error: %v", err)
   }
   utter.Config.BytesWidth = 8
   dump := utter.Sdump(b)
   t.Log(dump)
   if bytes.Contains(b, []byte("\r\n")) {
      t.Errorf("unexpected CRLF in unix file: %s", dump)
   }
}
```

Failing test on Travis with windows:
=== RUN   TestReadFile
--- FAIL: TestReadFile (0.00s)
    crlf_test.go:18: []uint8{
         0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x20, // |package |
         0x63, 0x72, 0x6c, 0x66, 0x0d, 0x0a, 0x0d, 0x0a, // |crlf....|
         0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x20, 0x28, // |import (|
         0x0d, 0x0a, 0x09, 0x22, 0x62, 0x79, 0x74, 0x65, // |..."byte|
         0x73, 0x22, 0x0d, 0x0a, 0x09, 0x22, 0x69, 0x6f, // |s"..."io|
         0x2f, 0x69, 0x6f, 0x75, 0x74, 0x69, 0x6c, 0x22, // |/ioutil"|
         0x0d, 0x0a, 0x09, 0x22, 0x74, 0x65, 0x73, 0x74, // |..."test|
         0x69, 0x6e, 0x67, 0x22, 0x0d, 0x0a, 0x0d, 0x0a, // |ing"....|
         0x09, 0x22, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, // |."github|
         0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x6f, 0x72, // |.com/kor|
         0x74, 0x73, 0x63, 0x68, 0x61, 0x6b, 0x2f, 0x75, // |tschak/u|
         0x74, 0x74, 0x65, 0x72, 0x22, 0x0d, 0x0a, 0x29, // |tter"..)|
         0x0d, 0x0a, 0x0d, 0x0a, 0x66, 0x75, 0x6e, 0x63, // |....func|
         0x20, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x61, // | TestRea|
         0x64, 0x46, 0x69, 0x6c, 0x65, 0x28, 0x74, 0x20, // |dFile(t |
         0x2a, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, // |*testing|
         0x2e, 0x54, 0x29, 0x20, 0x7b, 0x0d, 0x0a, 0x09, // |.T) {...|
         0x62, 0x2c, 0x20, 0x65, 0x72, 0x72, 0x20, 0x3a, // |b, err :|
         0x3d, 0x20, 0x69, 0x6f, 0x75, 0x74, 0x69, 0x6c, // |= ioutil|
         0x2e, 0x52, 0x65, 0x61, 0x64, 0x46, 0x69, 0x6c, // |.ReadFil|
         0x65, 0x28, 0x22, 0x63, 0x72, 0x6c, 0x66, 0x5f, // |e("crlf_|
         0x74, 0x65, 0x73, 0x74, 0x2e, 0x67, 0x6f, 0x22, // |test.go"|
         0x29, 0x0d, 0x0a, 0x09, 0x69, 0x66, 0x20, 0x65, // |)...if e|
         0x72, 0x72, 0x20, 0x21, 0x3d, 0x20, 0x6e, 0x69, // |rr != ni|
         0x6c, 0x20, 0x7b, 0x0d, 0x0a, 0x09, 0x09, 0x74, // |l {....t|
         0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x66, 0x28, // |.Errorf(|
         0x22, 0x75, 0x6e, 0x65, 0x78, 0x70, 0x65, 0x63, // |"unexpec|
         0x74, 0x65, 0x64, 0x20, 0x65, 0x72, 0x72, 0x6f, // |ted erro|
         0x72, 0x3a, 0x20, 0x25, 0x76, 0x22, 0x2c, 0x20, // |r: %v", |
         0x65, 0x72, 0x72, 0x29, 0x0d, 0x0a, 0x09, 0x7d, // |err)...}|
         0x0d, 0x0a, 0x09, 0x75, 0x74, 0x74, 0x65, 0x72, // |...utter|
         0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, // |.Config.|
         0x42, 0x79, 0x74, 0x65, 0x73, 0x57, 0x69, 0x64, // |BytesWid|
         0x74, 0x68, 0x20, 0x3d, 0x20, 0x38, 0x0d, 0x0a, // |th = 8..|
         0x09, 0x64, 0x75, 0x6d, 0x70, 0x20, 0x3a, 0x3d, // |.dump :=|
         0x20, 0x75, 0x74, 0x74, 0x65, 0x72, 0x2e, 0x53, // | utter.S|
         0x64, 0x75, 0x6d, 0x70, 0x28, 0x62, 0x29, 0x0d, // |dump(b).|
         0x0a, 0x09, 0x74, 0x2e, 0x4c, 0x6f, 0x67, 0x28, // |..t.Log(|
         0x64, 0x75, 0x6d, 0x70, 0x29, 0x0d, 0x0a, 0x09, // |dump)...|
         0x69, 0x66, 0x20, 0x62, 0x79, 0x74, 0x65, 0x73, // |if bytes|
         0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, // |.Contain|
         0x73, 0x28, 0x62, 0x2c, 0x20, 0x5b, 0x5d, 0x62, // |s(b, []b|
         0x79, 0x74, 0x65, 0x28, 0x22, 0x5c, 0x72, 0x5c, // |yte("\r\|
         0x6e, 0x22, 0x29, 0x29, 0x20, 0x7b, 0x0d, 0x0a, // |n")) {..|
         0x09, 0x09, 0x74, 0x2e, 0x45, 0x72, 0x72, 0x6f, // |..t.Erro|
         0x72, 0x66, 0x28, 0x22, 0x75, 0x6e, 0x65, 0x78, // |rf("unex|
         0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x20, 0x43, // |pected C|
         0x52, 0x4c, 0x46, 0x20, 0x69, 0x6e, 0x20, 0x75, // |RLF in u|
         0x6e, 0x69, 0x78, 0x20, 0x66, 0x69, 0x6c, 0x65, // |nix file|
         0x3a, 0x20, 0x25, 0x73, 0x22, 0x2c, 0x20, 0x64, // |: %s", d|
         0x75, 0x6d, 0x70, 0x29, 0x0d, 0x0a, 0x09, 0x7d, // |ump)...}|
         0x0d, 0x0a, 0x7d, 0x0d, 0x0a, /*             */ // |..}..|
        }
        
    crlf_test.go:20: unexpected CRLF in unix file: []uint8{
         0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x20, // |package |
         0x63, 0x72, 0x6c, 0x66, 0x0d, 0x0a, 0x0d, 0x0a, // |crlf....|
         0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x20, 0x28, // |import (|
         0x0d, 0x0a, 0x09, 0x22, 0x62, 0x79, 0x74, 0x65, // |..."byte|
         0x73, 0x22, 0x0d, 0x0a, 0x09, 0x22, 0x69, 0x6f, // |s"..."io|
         0x2f, 0x69, 0x6f, 0x75, 0x74, 0x69, 0x6c, 0x22, // |/ioutil"|
         0x0d, 0x0a, 0x09, 0x22, 0x74, 0x65, 0x73, 0x74, // |..."test|
         0x69, 0x6e, 0x67, 0x22, 0x0d, 0x0a, 0x0d, 0x0a, // |ing"....|
         0x09, 0x22, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, // |."github|
         0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x6f, 0x72, // |.com/kor|
         0x74, 0x73, 0x63, 0x68, 0x61, 0x6b, 0x2f, 0x75, // |tschak/u|
         0x74, 0x74, 0x65, 0x72, 0x22, 0x0d, 0x0a, 0x29, // |tter"..)|
         0x0d, 0x0a, 0x0d, 0x0a, 0x66, 0x75, 0x6e, 0x63, // |....func|
         0x20, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x61, // | TestRea|
         0x64, 0x46, 0x69, 0x6c, 0x65, 0x28, 0x74, 0x20, // |dFile(t |
         0x2a, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, // |*testing|
         0x2e, 0x54, 0x29, 0x20, 0x7b, 0x0d, 0x0a, 0x09, // |.T) {...|
         0x62, 0x2c, 0x20, 0x65, 0x72, 0x72, 0x20, 0x3a, // |b, err :|
         0x3d, 0x20, 0x69, 0x6f, 0x75, 0x74, 0x69, 0x6c, // |= ioutil|
         0x2e, 0x52, 0x65, 0x61, 0x64, 0x46, 0x69, 0x6c, // |.ReadFil|
         0x65, 0x28, 0x22, 0x63, 0x72, 0x6c, 0x66, 0x5f, // |e("crlf_|
         0x74, 0x65, 0x73, 0x74, 0x2e, 0x67, 0x6f, 0x22, // |test.go"|
         0x29, 0x0d, 0x0a, 0x09, 0x69, 0x66, 0x20, 0x65, // |)...if e|
         0x72, 0x72, 0x20, 0x21, 0x3d, 0x20, 0x6e, 0x69, // |rr != ni|
         0x6c, 0x20, 0x7b, 0x0d, 0x0a, 0x09, 0x09, 0x74, // |l {....t|
         0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x66, 0x28, // |.Errorf(|
         0x22, 0x75, 0x6e, 0x65, 0x78, 0x70, 0x65, 0x63, // |"unexpec|
         0x74, 0x65, 0x64, 0x20, 0x65, 0x72, 0x72, 0x6f, // |ted erro|
         0x72, 0x3a, 0x20, 0x25, 0x76, 0x22, 0x2c, 0x20, // |r: %v", |
         0x65, 0x72, 0x72, 0x29, 0x0d, 0x0a, 0x09, 0x7d, // |err)...}|
         0x0d, 0x0a, 0x09, 0x75, 0x74, 0x74, 0x65, 0x72, // |...utter|
         0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, // |.Config.|
         0x42, 0x79, 0x74, 0x65, 0x73, 0x57, 0x69, 0x64, // |BytesWid|
         0x74, 0x68, 0x20, 0x3d, 0x20, 0x38, 0x0d, 0x0a, // |th = 8..|
         0x09, 0x64, 0x75, 0x6d, 0x70, 0x20, 0x3a, 0x3d, // |.dump :=|
         0x20, 0x75, 0x74, 0x74, 0x65, 0x72, 0x2e, 0x53, // | utter.S|
         0x64, 0x75, 0x6d, 0x70, 0x28, 0x62, 0x29, 0x0d, // |dump(b).|
         0x0a, 0x09, 0x74, 0x2e, 0x4c, 0x6f, 0x67, 0x28, // |..t.Log(|
         0x64, 0x75, 0x6d, 0x70, 0x29, 0x0d, 0x0a, 0x09, // |dump)...|
         0x69, 0x66, 0x20, 0x62, 0x79, 0x74, 0x65, 0x73, // |if bytes|
         0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, // |.Contain|
         0x73, 0x28, 0x62, 0x2c, 0x20, 0x5b, 0x5d, 0x62, // |s(b, []b|
         0x79, 0x74, 0x65, 0x28, 0x22, 0x5c, 0x72, 0x5c, // |yte("\r\|
         0x6e, 0x22, 0x29, 0x29, 0x20, 0x7b, 0x0d, 0x0a, // |n")) {..|
         0x09, 0x09, 0x74, 0x2e, 0x45, 0x72, 0x72, 0x6f, // |..t.Erro|
         0x72, 0x66, 0x28, 0x22, 0x75, 0x6e, 0x65, 0x78, // |rf("unex|
         0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x20, 0x43, // |pected C|
         0x52, 0x4c, 0x46, 0x20, 0x69, 0x6e, 0x20, 0x75, // |RLF in u|
         0x6e, 0x69, 0x78, 0x20, 0x66, 0x69, 0x6c, 0x65, // |nix file|
         0x3a, 0x20, 0x25, 0x73, 0x22, 0x2c, 0x20, 0x64, // |: %s", d|
         0x75, 0x6d, 0x70, 0x29, 0x0d, 0x0a, 0x09, 0x7d, // |ump)...}|
         0x0d, 0x0a, 0x7d, 0x0d, 0x0a, /*             */ // |..}..|
        }
FAIL
FAIL gonum.org/v1/gonum/crlf 0.587s


Passing test on AppVeyor:
=== RUN   TestReadFile
--- PASS: TestReadFile (0.00s)
    crlf_test.go:18: []uint8{
         0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x20, // |package |
         0x63, 0x72, 0x6c, 0x66, 0x0a, 0x0a, 0x69, 0x6d, // |crlf..im|
         0x70, 0x6f, 0x72, 0x74, 0x20, 0x28, 0x0a, 0x09, // |port (..|
         0x22, 0x62, 0x79, 0x74, 0x65, 0x73, 0x22, 0x0a, // |"bytes".|
         0x09, 0x22, 0x69, 0x6f, 0x2f, 0x69, 0x6f, 0x75, // |."io/iou|
         0x74, 0x69, 0x6c, 0x22, 0x0a, 0x09, 0x22, 0x74, // |til".."t|
         0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x22, 0x0a, // |esting".|
         0x0a, 0x09, 0x22, 0x67, 0x69, 0x74, 0x68, 0x75, // |.."githu|
         0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x6f, // |b.com/ko|
         0x72, 0x74, 0x73, 0x63, 0x68, 0x61, 0x6b, 0x2f, // |rtschak/|
         0x75, 0x74, 0x74, 0x65, 0x72, 0x22, 0x0a, 0x29, // |utter".)|
         0x0a, 0x0a, 0x66, 0x75, 0x6e, 0x63, 0x20, 0x54, // |..func T|
         0x65, 0x73, 0x74, 0x52, 0x65, 0x61, 0x64, 0x46, // |estReadF|
         0x69, 0x6c, 0x65, 0x28, 0x74, 0x20, 0x2a, 0x74, // |ile(t *t|
         0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x54, // |esting.T|
         0x29, 0x20, 0x7b, 0x0a, 0x09, 0x62, 0x2c, 0x20, // |) {..b, |
         0x65, 0x72, 0x72, 0x20, 0x3a, 0x3d, 0x20, 0x69, // |err := i|
         0x6f, 0x75, 0x74, 0x69, 0x6c, 0x2e, 0x52, 0x65, // |outil.Re|
         0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x28, 0x22, // |adFile("|
         0x63, 0x72, 0x6c, 0x66, 0x5f, 0x74, 0x65, 0x73, // |crlf_tes|
         0x74, 0x2e, 0x67, 0x6f, 0x22, 0x29, 0x0a, 0x09, // |t.go")..|
         0x69, 0x66, 0x20, 0x65, 0x72, 0x72, 0x20, 0x21, // |if err !|
         0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x20, 0x7b, 0x0a, // |= nil {.|
         0x09, 0x09, 0x74, 0x2e, 0x45, 0x72, 0x72, 0x6f, // |..t.Erro|
         0x72, 0x66, 0x28, 0x22, 0x75, 0x6e, 0x65, 0x78, // |rf("unex|
         0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x20, 0x65, // |pected e|
         0x72, 0x72, 0x6f, 0x72, 0x3a, 0x20, 0x25, 0x76, // |rror: %v|
         0x22, 0x2c, 0x20, 0x65, 0x72, 0x72, 0x29, 0x0a, // |", err).|
         0x09, 0x7d, 0x0a, 0x09, 0x75, 0x74, 0x74, 0x65, // |.}..utte|
         0x72, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, // |r.Config|
         0x2e, 0x42, 0x79, 0x74, 0x65, 0x73, 0x57, 0x69, // |.BytesWi|
         0x64, 0x74, 0x68, 0x20, 0x3d, 0x20, 0x38, 0x0a, // |dth = 8.|
         0x09, 0x64, 0x75, 0x6d, 0x70, 0x20, 0x3a, 0x3d, // |.dump :=|
         0x20, 0x75, 0x74, 0x74, 0x65, 0x72, 0x2e, 0x53, // | utter.S|
         0x64, 0x75, 0x6d, 0x70, 0x28, 0x62, 0x29, 0x0a, // |dump(b).|
         0x09, 0x74, 0x2e, 0x4c, 0x6f, 0x67, 0x28, 0x64, // |.t.Log(d|
         0x75, 0x6d, 0x70, 0x29, 0x0a, 0x09, 0x69, 0x66, // |ump)..if|
         0x20, 0x62, 0x79, 0x74, 0x65, 0x73, 0x2e, 0x43, // | bytes.C|
         0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x73, 0x28, // |ontains(|
         0x62, 0x2c, 0x20, 0x5b, 0x5d, 0x62, 0x79, 0x74, // |b, []byt|
         0x65, 0x28, 0x22, 0x5c, 0x72, 0x5c, 0x6e, 0x22, // |e("\r\n"|
         0x29, 0x29, 0x20, 0x7b, 0x0a, 0x09, 0x09, 0x74, // |)) {...t|
         0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x66, 0x28, // |.Errorf(|
         0x22, 0x75, 0x6e, 0x65, 0x78, 0x70, 0x65, 0x63, // |"unexpec|
         0x74, 0x65, 0x64, 0x20, 0x43, 0x52, 0x4c, 0x46, // |ted CRLF|
         0x20, 0x69, 0x6e, 0x20, 0x75, 0x6e, 0x69, 0x78, // | in unix|
         0x20, 0x66, 0x69, 0x6c, 0x65, 0x3a, 0x20, 0x25, // | file: %|
         0x73, 0x22, 0x2c, 0x20, 0x64, 0x75, 0x6d, 0x70, // |s", dump|
         0x29, 0x0a, 0x09, 0x7d, 0x0a, 0x7d, 0x0a, /* */ // |)..}.}.|
        }
        
PASS
ok    gonum.org/v1/gonum/crlf 0.044s


Passing test on Travis on Linux:
=== RUN   TestReadFile
--- PASS: TestReadFile (0.00s)
    crlf_test.go:18: []uint8{
         0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x20, // |package |
         0x63, 0x72, 0x6c, 0x66, 0x0a, 0x0a, 0x69, 0x6d, // |crlf..im|
         0x70, 0x6f, 0x72, 0x74, 0x20, 0x28, 0x0a, 0x09, // |port (..|
         0x22, 0x62, 0x79, 0x74, 0x65, 0x73, 0x22, 0x0a, // |"bytes".|
         0x09, 0x22, 0x69, 0x6f, 0x2f, 0x69, 0x6f, 0x75, // |."io/iou|
         0x74, 0x69, 0x6c, 0x22, 0x0a, 0x09, 0x22, 0x74, // |til".."t|
         0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x22, 0x0a, // |esting".|
         0x0a, 0x09, 0x22, 0x67, 0x69, 0x74, 0x68, 0x75, // |.."githu|
         0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x6f, // |b.com/ko|
         0x72, 0x74, 0x73, 0x63, 0x68, 0x61, 0x6b, 0x2f, // |rtschak/|
         0x75, 0x74, 0x74, 0x65, 0x72, 0x22, 0x0a, 0x29, // |utter".)|
         0x0a, 0x0a, 0x66, 0x75, 0x6e, 0x63, 0x20, 0x54, // |..func T|
         0x65, 0x73, 0x74, 0x52, 0x65, 0x61, 0x64, 0x46, // |estReadF|
         0x69, 0x6c, 0x65, 0x28, 0x74, 0x20, 0x2a, 0x74, // |ile(t *t|
         0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x54, // |esting.T|
         0x29, 0x20, 0x7b, 0x0a, 0x09, 0x62, 0x2c, 0x20, // |) {..b, |
         0x65, 0x72, 0x72, 0x20, 0x3a, 0x3d, 0x20, 0x69, // |err := i|
         0x6f, 0x75, 0x74, 0x69, 0x6c, 0x2e, 0x52, 0x65, // |outil.Re|
         0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x28, 0x22, // |adFile("|
         0x63, 0x72, 0x6c, 0x66, 0x5f, 0x74, 0x65, 0x73, // |crlf_tes|
         0x74, 0x2e, 0x67, 0x6f, 0x22, 0x29, 0x0a, 0x09, // |t.go")..|
         0x69, 0x66, 0x20, 0x65, 0x72, 0x72, 0x20, 0x21, // |if err !|
         0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x20, 0x7b, 0x0a, // |= nil {.|
         0x09, 0x09, 0x74, 0x2e, 0x45, 0x72, 0x72, 0x6f, // |..t.Erro|
         0x72, 0x66, 0x28, 0x22, 0x75, 0x6e, 0x65, 0x78, // |rf("unex|
         0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x20, 0x65, // |pected e|
         0x72, 0x72, 0x6f, 0x72, 0x3a, 0x20, 0x25, 0x76, // |rror: %v|
         0x22, 0x2c, 0x20, 0x65, 0x72, 0x72, 0x29, 0x0a, // |", err).|
         0x09, 0x7d, 0x0a, 0x09, 0x75, 0x74, 0x74, 0x65, // |.}..utte|
         0x72, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, // |r.Config|
         0x2e, 0x42, 0x79, 0x74, 0x65, 0x73, 0x57, 0x69, // |.BytesWi|
         0x64, 0x74, 0x68, 0x20, 0x3d, 0x20, 0x38, 0x0a, // |dth = 8.|
         0x09, 0x64, 0x75, 0x6d, 0x70, 0x20, 0x3a, 0x3d, // |.dump :=|
         0x20, 0x75, 0x74, 0x74, 0x65, 0x72, 0x2e, 0x53, // | utter.S|
         0x64, 0x75, 0x6d, 0x70, 0x28, 0x62, 0x29, 0x0a, // |dump(b).|
         0x09, 0x74, 0x2e, 0x4c, 0x6f, 0x67, 0x28, 0x64, // |.t.Log(d|
         0x75, 0x6d, 0x70, 0x29, 0x0a, 0x09, 0x69, 0x66, // |ump)..if|
         0x20, 0x62, 0x79, 0x74, 0x65, 0x73, 0x2e, 0x43, // | bytes.C|
         0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x73, 0x28, // |ontains(|
         0x62, 0x2c, 0x20, 0x5b, 0x5d, 0x62, 0x79, 0x74, // |b, []byt|
         0x65, 0x28, 0x22, 0x5c, 0x72, 0x5c, 0x6e, 0x22, // |e("\r\n"|
         0x29, 0x29, 0x20, 0x7b, 0x0a, 0x09, 0x09, 0x74, // |)) {...t|
         0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x66, 0x28, // |.Errorf(|
         0x22, 0x75, 0x6e, 0x65, 0x78, 0x70, 0x65, 0x63, // |"unexpec|
         0x74, 0x65, 0x64, 0x20, 0x43, 0x52, 0x4c, 0x46, // |ted CRLF|
         0x20, 0x69, 0x6e, 0x20, 0x75, 0x6e, 0x69, 0x78, // | in unix|
         0x20, 0x66, 0x69, 0x6c, 0x65, 0x3a, 0x20, 0x25, // | file: %|
         0x73, 0x22, 0x2c, 0x20, 0x64, 0x75, 0x6d, 0x70, // |s", dump|
         0x29, 0x0a, 0x09, 0x7d, 0x0a, 0x7d, 0x0a, /* */ // |)..}.}.|
        }
        
PASS
ok    gonum.org/v1/gonum/crlf 0.036s

Dan Kortschak

unread,
Apr 22, 2019, 6:39:54 PM4/22/19
to golang-nuts
Solved. This is Travis being "helpful" and setting core.autocrlf=true
in git config.

https://travis-ci.community/t/files-in-checkout-have-eol-changed-from-l
f-to-crlf/349/4

Constantin Konstantinidis

unread,
Apr 23, 2019, 1:38:20 PM4/23/19
to golang-nuts
$ git version
git version 2.20.1.windows.1
$ go version
go version go1.12.2 windows/amd64
$ git config -l | grep autocrlf
core.autocrlf=true
core.autocrlf=true

Same issue remains intermittent. It is reproducible using git checkout -- <your-file>
Discarding changes sets default back to CRLF.
I could not locate the root cause.
Reply all
Reply to author
Forward
0 new messages