csv

package module
v0.0.0-...-94f23d6 Latest Latest
Warning

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

Go to latest
Published: May 5, 2018 License: BSD-2-Clause Imports: 9 Imported by: 1

README

h12.io/csv: CSV <=> Go Struct

Encoding and decoding between CSV and Go struct:

  • nested Go struct supported
  • slice/array expansion supported
TODO
  • Decoder

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(v interface{}) ([]byte, error)

Types

type Encoder

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

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

func (*Encoder) Encode

func (e *Encoder) Encode(value interface{}) error

func (*Encoder) EncodeHeader

func (e *Encoder) EncodeHeader(value interface{}) error

func (*Encoder) Fields

func (e *Encoder) Fields() Fields

func (*Encoder) SetDelimiter

func (e *Encoder) SetDelimiter(delim rune) *Encoder

func (*Encoder) SetExpandPath

func (e *Encoder) SetExpandPath(path ...string) *Encoder

func (*Encoder) SetLineBreak

func (e *Encoder) SetLineBreak(lineBreak string) *Encoder

func (*Encoder) SetTagKey

func (e *Encoder) SetTagKey(tagKey string) *Encoder

type Field

type Field struct {
	Name  string
	Value string
	Tag   Tag
}

type Fields

type Fields []Field

func (Fields) Len

func (a Fields) Len() int

func (Fields) Less

func (a Fields) Less(i, j int) bool

func (Fields) Names

func (a Fields) Names() []string

func (Fields) Swap

func (a Fields) Swap(i, j int)

func (Fields) Values

func (a Fields) Values() []string

type Tag

type Tag string

A StructTag is the tag string in a struct field.

By convention, tag strings are a concatenation of optionally space-separated key:"value" pairs. Each key is a non-empty string consisting of non-control characters other than space (U+0020 ' '), quote (U+0022 '"'), and colon (U+003A ':'). Each value is quoted using U+0022 '"' characters and Go string literal syntax.

func (Tag) Get

func (tag Tag) Get(key string) string

Get returns the value associated with key in the tag string. If there is no such key in the tag, Get returns the empty string. If the tag does not have the conventional format, the value returned by Get is unspecified.

func (Tag) Has

func (tag Tag) Has(key string) bool

type Tags

type Tags []Tag

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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