Latest Threat ResearchGlassWorm Loader Hits Open VSX via Developer Account Compromise.Details
Socket
Book a DemoInstallSign in
Socket

vimagination.zapto.org/dos2unix

Package Overview
Dependencies
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vimagination.zapto.org/dos2unix

Go Modules
Version
v1.0.2
Version published
Created
Source

dos2unix

CI Go Reference Go Report Card

-- 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)
	// Output: "hello\nworld\n"

	input = strings.NewReader("hello\nworld\n")
	ud := dos2unix.Unix2DOS(input)
	out, _ := io.ReadAll(ud)

	fmt.Printf("%q\n", out)
	// Output: "hello\r\nworld\r\n"
}

Documentation

Full API docs can be found at:

https://pkg.go.dev/vimagination.zapto.org/dos2unix

FAQs

Package last updated on 20 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts