Skip to content
This repository has been archived by the owner on Nov 25, 2019. It is now read-only.

Commit

Permalink
Removed code to make tools work with standard Windows line endings
Browse files Browse the repository at this point in the history
  • Loading branch information
dlwyatt committed Dec 15, 2017
1 parent 3026b4f commit af56498
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions ptimports/ptimports.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,16 @@ func processFile(filename string, in io.Reader) error {
return err
}

// Normalize for comparison
crLfBytes := []byte("\r\n")
lfBytes := []byte("\n")
nrmlSrc := bytes.Replace(src, crLfBytes, lfBytes, -1)
nrmlRes := bytes.Replace(res, crLfBytes, lfBytes, -1)

if *list {
if !bytes.Equal(nrmlSrc, nrmlRes) {
if !bytes.Equal(src, res) {
fmt.Println(filename)
}
return nil
}

if *write {
// only write when file changed
if !bytes.Equal(nrmlSrc, nrmlRes) {
if !bytes.Equal(src, res) {
return ioutil.WriteFile(filename, res, 0)
}
} else {
Expand Down

0 comments on commit af56498

Please sign in to comment.