data

package
v2.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2017 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CSV

func CSV(args ...string) [][]string

CSV - Unmarshal CSV parameters:

delim - (optional) the (single-character!) field delimiter, defaults to ","
   in - the CSV-format string to parse

returns:

an array of rows, which are arrays of cells (strings)

func CSVByColumn

func CSVByColumn(args ...string) (cols map[string][]string)

CSVByColumn - Unmarshal CSV in a Columnar form parameters:

delim - (optional) the (single-character!) field delimiter, defaults to ","
  hdr - (optional) comma-separated list of column names,
        set to "" to get auto-named columns (A-Z), omit
        to use the first line
   in - the CSV-format string to parse

returns:

a map of columns, indexed by the header name. values are arrays of strings

func CSVByRow

func CSVByRow(args ...string) (rows []map[string]string)

CSVByRow - Unmarshal CSV in a row-oriented form parameters:

delim - (optional) the (single-character!) field delimiter, defaults to ","
  hdr - (optional) comma-separated list of column names,
        set to "" to get auto-named columns (A-Z), omit
        to use the first line
   in - the CSV-format string to parse

returns:

an array of rows, indexed by the header name

func JSON

func JSON(in string) map[string]interface{}

JSON - Unmarshal a JSON Object

func JSONArray

func JSONArray(in string) []interface{}

JSONArray - Unmarshal a JSON Array

func TOML

func TOML(in string) interface{}

TOML - Unmarshal a TOML Object

func ToCSV

func ToCSV(args ...interface{}) string

ToCSV -

func ToJSON

func ToJSON(in interface{}) string

ToJSON - Stringify a struct as JSON

func ToJSONPretty

func ToJSONPretty(indent string, in interface{}) string

ToJSONPretty - Stringify a struct as JSON (indented)

func ToTOML

func ToTOML(in interface{}) string

ToTOML - Stringify a struct as TOML

func ToYAML

func ToYAML(in interface{}) string

ToYAML - Stringify a struct as YAML

func YAML

func YAML(in string) map[string]interface{}

YAML - Unmarshal a YAML Object

func YAMLArray

func YAMLArray(in string) []interface{}

YAMLArray - Unmarshal a YAML Array

Types

type Data

type Data struct {
	Sources map[string]*Source
	// contains filtered or unexported fields
}

Data -

func NewData

func NewData(datasourceArgs []string, headerArgs []string) *Data

NewData - constructor for Data

func (*Data) Cleanup

func (d *Data) Cleanup()

Cleanup - clean up datasources before shutting the process down - things like Logging out happen here

func (*Data) Datasource

func (d *Data) Datasource(alias string, args ...string) interface{}

Datasource -

func (*Data) DatasourceExists

func (d *Data) DatasourceExists(alias string) bool

DatasourceExists -

func (*Data) Include

func (d *Data) Include(alias string, args ...string) string

Include -

func (*Data) ReadSource

func (d *Data) ReadSource(source *Source, args ...string) ([]byte, error)

ReadSource -

type Source

type Source struct {
	Alias  string
	URL    *url.URL
	Ext    string
	Type   string
	Params map[string]string
	FS     vfs.Filesystem // used for file: URLs, nil otherwise
	HC     *http.Client   // used for http[s]: URLs, nil otherwise
	VC     *vault.Vault   // used for vault: URLs, nil otherwise
	KV     *libkv.LibKV   // used for consul:, etcd:, zookeeper: & boltdb: URLs, nil otherwise
	Header http.Header    // used for http[s]: URLs, nil otherwise
}

Source - a data source

func NewSource

func NewSource(alias string, URL *url.URL) (s *Source)

NewSource - builds a &Source

func ParseSource

func ParseSource(value string) (*Source, error)

ParseSource -

func (*Source) String

func (s *Source) String() string

String is the method to format the flag's value, part of the flag.Value interface. The String method's output will be used in diagnostics.

Jump to

Keyboard shortcuts

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