Help us shape the future of Go! Take the 2026 Go Developer Survey

csv

package
v0.201.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 21 Imported by: 21

Documentation

Overview

Package csv contains the csv result encoders and decoders.

Index

Constants

View Source
const DialectType = "csv"

Variables

This section is empty.

Functions

func AddDialectMappings

func AddDialectMappings(mappings flux.DialectMappings) error

AddDialectMappings adds the influxql specific dialect mappings.

Types

type Dialect

type Dialect struct {
	ResultEncoderConfig
}

Dialect describes the output format of queries in CSV.

func DefaultDialect

func DefaultDialect() *Dialect

func (Dialect) DialectType

func (d Dialect) DialectType() flux.DialectType

func (Dialect) Encoder

func (d Dialect) Encoder() flux.MultiResultEncoder

func (Dialect) SetHeaders

func (d Dialect) SetHeaders(w http.ResponseWriter)

type MultiResultDecoder

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

MultiResultDecoder reads multiple results from a single csv file. Results are delimited by an empty line.

func NewMultiResultDecoder

func NewMultiResultDecoder(c ResultDecoderConfig) *MultiResultDecoder

NewMultiResultDecoder creates a new MultiResultDecoder.

func (*MultiResultDecoder) Decode

type ResultDecoder

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

ResultDecoder decodes a csv representation of a result.

func NewResultDecoder

func NewResultDecoder(c ResultDecoderConfig) *ResultDecoder

NewResultDecoder creates a new ResultDecoder.

func (*ResultDecoder) Decode

func (d *ResultDecoder) Decode(r io.Reader) (flux.Result, error)

type ResultDecoderConfig

type ResultDecoderConfig struct {
	// NoAnnotations indicates that the CSV data will not have annotations rows.
	// Without annotations the decoder will assume every column is of type string and
	// that all data is in a single table in a single result.
	NoAnnotations bool
	// NoHeader indicates that the CSV data will not have a header row.
	NoHeader bool
	// MaxBufferCount is the maximum number of rows that will be buffered when decoding.
	// If 0, then a value of 1000 will be used.
	MaxBufferCount int
	// Allocator is the memory allocator that will be used during decoding.
	// The default is to use an unlimited allocator when this is not set.
	Allocator memory.Allocator
	// Context is the context for this ResultDecoder.
	// When the context is canceled, the decoder will also be canceled.
	// This defaults to context.Background.
	Context context.Context
}

ResultDecoderConfig are options that can be specified on the ResultDecoder.

type ResultEncoder

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

func NewResultEncoder

func NewResultEncoder(c ResultEncoderConfig) *ResultEncoder

NewResultEncoder creates a new encoder with the provided configuration.

func (*ResultEncoder) Encode

func (e *ResultEncoder) Encode(w io.Writer, result flux.Result) (int64, error)

func (*ResultEncoder) EncodeError

func (e *ResultEncoder) EncodeError(w io.Writer, err error) error

type ResultEncoderConfig

type ResultEncoderConfig struct {
	// Annotations is a list of annotations to include.
	Annotations []string

	// NoHeader indicates whether a header row should be added.
	NoHeader bool

	// If present, add the download header matching this AttachmentFilename.
	AttachmentFilename string

	// Delimiter is the character to delimite columns.
	// It must not be \r, \n, or the Unicode replacement character (0xFFFD).
	Delimiter rune
}

ResultEncoderConfig are options that can be specified on the ResultEncoder.

func DefaultEncoderConfig

func DefaultEncoderConfig() ResultEncoderConfig

func (ResultEncoderConfig) MarshalJSON

func (c ResultEncoderConfig) MarshalJSON() ([]byte, error)

func (*ResultEncoderConfig) UnmarshalJSON

func (c *ResultEncoderConfig) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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