encoding

package
v0.0.0-...-a0cf6f9 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package encoding handles the encoding process for CSV, TSV, and fixed length text.

Package encoding handles the encoding process for CSV, TSV, and fixed length text.

Package encoding handles the encoding process for CSV, TSV, and fixed length text.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CsvEncoderOptions

type CsvEncoderOptions struct {
	// Charset is an output character code (default: charset.UTF8)
	Charset charset.Charset
	// Separator default: ','
	Separator rune
	// OmitHeader is whether to skip generating the header on the first line from the field from the structure definition
	OmitHeader bool
	// Newline default: LF
	Newline newline.Newline
}

CsvEncoderOptions is an optional argument to NewCsvEncoder.

type Encoder

type Encoder[TRow any] interface {
	// Encode encodes and writes arguments.
	Encode(row TRow) error
	// Flush flushes data. Call this before the end of processing.
	Flush() error
}

Encoder handles the encoding of CSV, TSV, JSON, and fixed length text.

func NewCsvEncoder

func NewCsvEncoder[TRow any](dst io.Writer, opts CsvEncoderOptions) Encoder[TRow]

NewCsvEncoder creates an Encoder that processes CSV/TSV. See csvutil documentation for structure tags: https://github.com/jszwec/csvutil

func NewFixedWidthWriter

func NewFixedWidthWriter[TRow any](dst io.Writer, opts FixedWidthEncoderOptions) Encoder[TRow]

NewFixedWidthWriter creates an Encoder that generates a fixed length field. See csvutil documentation for structure tags: https://github.com/ianlopshire/go-fixedwidth

type FixedWidthEncoderOptions

type FixedWidthEncoderOptions struct {
	// Charset is an output character code (default: charset.UTF8)
	Charset charset.Charset
	// Newline default: LF
	Newline newline.Newline
}

Jump to

Keyboard shortcuts

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