output

package
v0.0.0-...-391253a Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 License: GPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultFileMode      = 0644
	DateTimeLayout       = "2006/01/02 15:04:05"
	DateTimeSearchLayout = "2006-01-02 15:04:05"
)
View Source
const (
	TypeNone     = iota
	TypeJson     = iota
	TypeCsv      = iota
	TypeList     = iota
	TypeTable    = iota
	TypeRaw      = iota
	TypeGraph    = iota
	TypeStruct   = iota
	TypeXML      = iota
	TypeXLSX     = iota
	TypeMarkDown = iota

	StringTypeNone     = ""
	StringTypeJson     = "json"
	StringTypeCsv      = "csv"
	StringTypeList     = "list"
	StringTypeTable    = "table"
	StringTypeRaw      = "raw"
	StringTypeGraph    = "graph"
	StringTypeStruct   = "struct"
	StringTypeXML      = "xml"
	StringTypeXLSX     = "xlsx"
	StringTypeMarkDown = "md"
)

Variables

This section is empty.

Functions

func DirExists

func DirExists(fn string) bool

DirExists - Checks if a directory exists.

func FileExists

func FileExists(fn string) bool

FileExists - Checks if a file exists.

func FileRead

func FileRead(fn string, ref interface{}) error

FileRead Retrieves data from a local file.

func FileRemove

func FileRemove(fn string) error

FileRemove Removes a file path.

func FileWrite

func FileWrite(fn string, ref interface{}, perm os.FileMode) error

FileWrite Saves data to a file path.

func GetAsString

func GetAsString(r interface{}) string

func GetEndPointString

func GetEndPointString(r interface{}) string

func GetRequestString

func GetRequestString(r interface{}) string

func Mkdir

func Mkdir(fn string) bool

Mkdir - Create dir.

func PlainFileRead

func PlainFileRead(fn string) ([]byte, error)

PlainFileRead Retrieves data from a local file.

func PlainFileWrite

func PlainFileWrite(fn string, data []byte, perm os.FileMode) error

PlainFileWrite Saves data to a file path.

Types

type Chart

type Chart struct {
	Error error `json:"-"`
	// contains filtered or unexported fields
}

func New

func New() *Chart

func (*Chart) Generate

func (c *Chart) Generate() error

func (*Chart) ProcessGraphData

func (c *Chart) ProcessGraphData(table *Table) error

func (*Chart) SetColumns

func (c *Chart) SetColumns(req GraphRequest) bool

func (*Chart) SetFilename

func (c *Chart) SetFilename(fn string) error

func (*Chart) SetHeight

func (c *Chart) SetHeight(v *int)

func (*Chart) SetRangeY

func (c *Chart) SetRangeY(min *float64, max *float64) bool

func (*Chart) SetTitle

func (c *Chart) SetTitle(title string) error

func (*Chart) SetWidth

func (c *Chart) SetWidth(v *int)

func (*Chart) SetX

func (c *Chart) SetX(name string, values ...time.Time) error

func (*Chart) SetY

func (c *Chart) SetY(name string, values ...float64) error

func (*Chart) SetY2

func (c *Chart) SetY2(name string, values ...float64) error

type GraphRequest

type GraphRequest struct {
	Title    string `json:"title"`
	SubTitle string `json:"sub_title"`

	TimeColumn  *string  `json:"time_column"`
	DataColumn  *string  `json:"value_column"`
	UnitsColumn *string  `json:"units_column"`
	NameColumn  *string  `json:"name_column"`
	DataUnit    *string  `json:"unit"`
	DataMin     *float64 `json:"min"`
	DataMax     *float64 `json:"max"`
	Width       *int     `json:"width"`
	Height      *int     `json:"height"`

	Error error `json:"-"`
}

func JsonToGraphRequest

func JsonToGraphRequest(j Json) GraphRequest

type Json

type Json string

func GetAsJson

func GetAsJson(r interface{}) Json

func GetAsPrettyJson

func GetAsPrettyJson(r interface{}) Json

func (Json) String

func (req Json) String() string

type OutputType

type OutputType int

func (*OutputType) IsCsv

func (out *OutputType) IsCsv() bool

func (*OutputType) IsGraph

func (out *OutputType) IsGraph() bool

func (*OutputType) IsJson

func (out *OutputType) IsJson() bool

func (*OutputType) IsList

func (out *OutputType) IsList() bool

func (*OutputType) IsMarkDown

func (out *OutputType) IsMarkDown() bool

func (*OutputType) IsNone

func (out *OutputType) IsNone() bool

func (*OutputType) IsRaw

func (out *OutputType) IsRaw() bool

func (*OutputType) IsStrCsv

func (out *OutputType) IsStrCsv(t string) bool

func (*OutputType) IsStrGraph

func (out *OutputType) IsStrGraph(t string) bool

func (*OutputType) IsStrJson

func (out *OutputType) IsStrJson(t string) bool

func (*OutputType) IsStrList

func (out *OutputType) IsStrList(t string) bool

func (*OutputType) IsStrMarkDown

func (out *OutputType) IsStrMarkDown(t string) bool

func (*OutputType) IsStrNone

func (out *OutputType) IsStrNone(t string) bool

func (*OutputType) IsStrRaw

func (out *OutputType) IsStrRaw(t string) bool

func (*OutputType) IsStrTable

func (out *OutputType) IsStrTable(t string) bool

func (*OutputType) IsStrXLSX

func (out *OutputType) IsStrXLSX(t string) bool

func (*OutputType) IsStrXML

func (out *OutputType) IsStrXML(t string) bool

func (*OutputType) IsStruct

func (out *OutputType) IsStruct() bool

func (*OutputType) IsTable

func (out *OutputType) IsTable() bool

func (*OutputType) IsXLSX

func (out *OutputType) IsXLSX() bool

func (*OutputType) IsXML

func (out *OutputType) IsXML() bool

func (*OutputType) Set

func (out *OutputType) Set(outputType string)

func (*OutputType) SetCsv

func (out *OutputType) SetCsv()

func (*OutputType) SetGraph

func (out *OutputType) SetGraph()

func (*OutputType) SetJson

func (out *OutputType) SetJson()

func (*OutputType) SetList

func (out *OutputType) SetList()

func (*OutputType) SetMarkDown

func (out *OutputType) SetMarkDown()

func (*OutputType) SetNone

func (out *OutputType) SetNone()

func (*OutputType) SetRaw

func (out *OutputType) SetRaw()

func (*OutputType) SetStruct

func (out *OutputType) SetStruct()

func (*OutputType) SetTable

func (out *OutputType) SetTable()

func (*OutputType) SetXLSX

func (out *OutputType) SetXLSX()

func (*OutputType) SetXML

func (out *OutputType) SetXML()

type Table

type Table struct {
	OutputType OutputType

	Error error
	// contains filtered or unexported fields
}

func NewTable

func NewTable(headers ...string) Table

func (*Table) AddRow

func (t *Table) AddRow(row ...interface{}) error

func (*Table) AppendFilePrefix

func (t *Table) AppendFilePrefix(prefix string, args ...interface{})

func (*Table) AppendRaw

func (t *Table) AppendRaw(data []byte)

func (*Table) AppendTitle

func (t *Table) AppendTitle(title string, args ...interface{})

func (*Table) AsCsv

func (t *Table) AsCsv() string

func (*Table) AsJson

func (t *Table) AsJson() string

func (*Table) AsMarkDown

func (t *Table) AsMarkDown() string

func (*Table) AsRaw

func (t *Table) AsRaw() string

func (*Table) AsRawBytes

func (t *Table) AsRawBytes() []byte

func (*Table) AsStruct

func (t *Table) AsStruct() string

func (*Table) AsTable

func (t *Table) AsTable() string

func (*Table) AsXLSX

func (t *Table) AsXLSX() string

func (*Table) AsXml

func (t *Table) AsXml() string

func (*Table) CreateGraph

func (t *Table) CreateGraph() error

func (*Table) GetCell

func (t *Table) GetCell(row int, colName string) (string, interface{}, error)

func (*Table) GetFilePrefix

func (t *Table) GetFilePrefix() string

func (*Table) GetHeaders

func (t *Table) GetHeaders() []string

func (*Table) GetName

func (t *Table) GetName() string

func (*Table) GetSortedHeaders

func (t *Table) GetSortedHeaders() []string

func (*Table) GetTitle

func (t *Table) GetTitle() string

func (*Table) InitGraph

func (t *Table) InitGraph(req GraphRequest)

func (*Table) IsNotValid

func (t *Table) IsNotValid() bool

func (*Table) IsValid

func (t *Table) IsValid() bool

func (*Table) Output

func (t *Table) Output() error

func (*Table) PrependFilePrefix

func (t *Table) PrependFilePrefix(prefix string, args ...interface{})

func (*Table) ProcessGraphData

func (t *Table) ProcessGraphData() error

func (*Table) RowLength

func (t *Table) RowLength() int

func (*Table) SetDirectory

func (t *Table) SetDirectory(prefix string, args ...interface{})

func (*Table) SetFilePrefix

func (t *Table) SetFilePrefix(prefix string, args ...interface{})

func (*Table) SetGraph

func (t *Table) SetGraph(req GraphRequest) error

func (*Table) SetGraphFilter

func (t *Table) SetGraphFilter(filter string)

func (*Table) SetGraphFromJson

func (t *Table) SetGraphFromJson(j Json) error

func (*Table) SetJson

func (t *Table) SetJson(data []byte)

func (*Table) SetName

func (t *Table) SetName(name string)

func (*Table) SetOutputType

func (t *Table) SetOutputType(outputType string)

func (*Table) SetRaw

func (t *Table) SetRaw(data []byte)

func (*Table) SetSaveFile

func (t *Table) SetSaveFile(ok bool)

func (*Table) SetTitle

func (t *Table) SetTitle(title string, args ...interface{})

func (*Table) Sort

func (t *Table) Sort(sort string)

func (Table) String

func (t Table) String() string

func (*Table) WriteCsv

func (t *Table) WriteCsv() error

func (*Table) WriteJson

func (t *Table) WriteJson() error

func (*Table) WriteList

func (t *Table) WriteList() error

func (*Table) WriteMarkDown

func (t *Table) WriteMarkDown() error

func (*Table) WriteRaw

func (t *Table) WriteRaw() error

func (*Table) WriteStruct

func (t *Table) WriteStruct() error

func (*Table) WriteTable

func (t *Table) WriteTable() error

func (*Table) WriteXLSX

func (t *Table) WriteXLSX() error

func (*Table) WriteXml

func (t *Table) WriteXml() error

type Tables

type Tables map[string]Table

func NewTables

func NewTables() Tables

func (*Tables) Sort

func (t *Tables) Sort() []string

Jump to

Keyboard shortcuts

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