Skip to content

andybalholm/crlf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

crlf

-- import "crlf"

The crlf package helps in dealing with files that have DOS-style CR/LF line endings.

Usage

func Create

func Create(name string) (io.WriteCloser, error)

Create opens a text file for writing, with platform-appropriate line ending conversion.

func NewReader

func NewReader(r io.Reader) io.Reader

NewReader returns an io.Reader that converts CR or CRLF line endings to LF.

func NewWriter

func NewWriter(w io.Writer) io.Writer

NewWriter returns an io.Writer that converts LF line endings to CRLF.

func Open

func Open(name string) (io.ReadCloser, error)

Open opens a text file for reading, with platform-appropriate line ending conversion.

type Normalize

type Normalize struct {
}

Normalize takes CRLF, CR, or LF line endings in src, and converts them to LF in dst.

func (*Normalize) Reset

func (n *Normalize) Reset()

func (*Normalize) Transform

func (n *Normalize) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error)

type ToCRLF

type ToCRLF struct{}

ToCRLF takes LF line endings in src, and converts them to CRLF in dst.

func (ToCRLF) Reset

func (ToCRLF) Reset()

func (ToCRLF) Transform

func (ToCRLF) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error)

About

handling CR/LF line endings in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages