txt

package
v0.1.73 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2024 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Export

func Export(contents []string, w io.Writer) error

Export writes contents to writer w.

func ExportFile

func ExportFile(contents []string, file string) error

ExportFile writes contents to file.

func ReadAll

func ReadAll(r io.Reader) []string

ReadAll reads all contents from r.

func ReadFile

func ReadFile(file string) ([]string, error)

ReadFile reads all contents from file.

Types

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

func NewReader

func NewReader(r io.Reader) *Reader

func (*Reader) Iter

func (r *Reader) Iter() iter.Seq[string]

type Writer

type Writer struct {
	*bufio.Writer
	UseCRLF bool // True to use \r\n as the line terminator
}

Writer implements buffering for an io.Writer object. If an error occurs writing to a Writer, no more data will be accepted and all subsequent writes, and Flush, will return the error. After all data has been written, the client should call the Flush method to guarantee all data has been forwarded to the underlying io.Writer.

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWriter returns a new text Writer whose buffer has the default size.

func NewWriterSize

func NewWriterSize(w io.Writer, size int) *Writer

NewWriterSize returns a new text Writer whose buffer has at least the specified size. If the argument io.Writer is already a Writer with large enough size, it returns the underlying Writer.

func (*Writer) WriteAll

func (w *Writer) WriteAll(contents []string) error

WriteAll writes contents to w using WriteLine and then calls Flush, returning any error from the Flush.

func (*Writer) WriteLine

func (w *Writer) WriteLine(s string) (int, error)

WriteLine writes a string end with the line terminator. It returns the number of bytes written. If the count is less than expected, it also returns an error explaining why the write is short.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL