csv

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package csv provides a builder for csv data

Index

Constants

View Source
const (
	DefaultFieldSeparator  = ","
	DefaultRecordSeparator = "\n"
	FieldSeparatorFlag     = "field-separator"
	RecordSeparatorFlag    = "record-separator"
)

Variables

This section is empty.

Functions

func Marshal

func Marshal(input interface{}, fieldSeparator, recordSeparator string) ([]byte, error)

Marshal marshals the object into JSON then converts JSON to CSV then returns the CSV.

Types

type Node

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

func NewCSVNode

func NewCSVNode(
	root *Node,
	parent *Node,
	headLocal string,
	headFull string,
	tail interface{},
) Node

NewCSVNode returns instance of preconfigured CSV Node. It contains the information needed to generate a header for data in corresponding CSV field.

func NewCSVRoot

func NewCSVRoot(
	tail interface{},
) Node

NewCSVRoot returns instance of preconfigured CSV Node. The returned node is a root of the graph.

func (*Node) ExpandTail

func (node *Node) ExpandTail() error

ExpandTail retrieves the values of all tails in the graph and creates the whole graph structure.

func (*Node) GetHeaders

func (node *Node) GetHeaders() ([]string, error)

GetHeaders returns an array of headers of all child nodes.

func (*Node) GetLeaves

func (node *Node) GetLeaves() []*Node

GetLeaves returns all leaves from the sub-tree starting from the specific node.

Jump to

Keyboard shortcuts

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