dos2unix

--
import "vimagination.zapto.org/dos2unix"
Package dos2unix provides functions to convert between dos and unix line termination styles.
Highlights
- DOS2Unix & Unix2DOS functions which wrap
io.Readers to automatically convert line terminations.
- DOS2UnixWriter & Unix2DOSWriter functions which wrap
io.Writers to automatically convert line terminations. NB: The Flush() method must be called once writing is finished.
Usage
package main
import (
"fmt"
"io"
"strings"
"vimagination.zapto.org/dos2unix"
)
func main() {
input := strings.NewReader("hello\r\nworld\r\n")
du := dos2unix.DOS2Unix(input)
out, _ := io.ReadAll(du)
fmt.Printf("%q\n", out)
input = strings.NewReader("hello\nworld\n")
ud := dos2unix.Unix2DOS(input)
out, _ := io.ReadAll(ud)
fmt.Printf("%q\n", out)
}
Documentation
Full API docs can be found at:
https://pkg.go.dev/vimagination.zapto.org/dos2unix