shared

package
v0.0.0-...-cbe141c Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseTime

func ParseTime(header string, dateFormat string) (time.Time, error)

GetHeaderTimeFromNode tries to parse node's time from the header and returns it as time.Time

Types

type APIError

type APIError struct {
	IsError bool   `json:"is_error"`
	Code    int    `json:"code"`
	Status  string `json:"status"`
	Message string `json:"message"`
}

APIError holds service error

func (APIError) Error

func (ae APIError) Error() string

type APINode

type APINode struct {
	Name         string    `json:"name"`
	Slug         string    `json:"slug"`
	Calories     float64   `json:"calories"`
	Fat          float64   `json:"fat"`
	Carbohydrate float64   `json:"carbohydrate"`
	Protein      float64   `json:"protein"`
	Barcode      string    `json:"barcode,omitempty"`
	UserID       string    `json:"-"`
	Created      time.Time `json:"created"`
}

APINode contains single node

type APINodeList

type APINodeList []APINode

APINodeList represents list of nodes

type DBNode

type DBNode struct {
	Header   string
	Elements Elements
}

DBNode contains general node data

func NewDBNodeFromNode

func NewDBNodeFromNode(n *ParserNode) *DBNode

NewDBNodeFromNode creates DB Node from Parser node

type DBNodeList

type DBNodeList map[string]*DBNode

DBNodeList contains list of general nodes

func NewDBNodeList

func NewDBNodeList() DBNodeList

NewDBNodeList creates new list of general nodes

func (*DBNodeList) Push

func (db *DBNodeList) Push(node *DBNode)

Push adds node to the node list

type Element

type Element struct {
	Name string
	Val  float64
}

Element contains single element data

func NewElement

func NewElement(name string, val float64) Element

NewElement creates new element

type Elements

type Elements []Element

Elements contains array of elements

func NewElements

func NewElements() Elements

NewElements creates new element list

func (*Elements) Add

func (el *Elements) Add(name string, val float64)

Add adds new element to the list

func (*Elements) Index

func (el *Elements) Index(name string) (int, bool)

Index returns the index of the element by name

func (Elements) Len

func (el Elements) Len() int

Len returns the length of the element list

func (Elements) Less

func (el Elements) Less(i, j int) bool

Less compares two elements

func (Elements) Sort

func (el Elements) Sort()

Sort sorts the element list

func (*Elements) SumMerge

func (el *Elements) SumMerge(left Elements, mult float64)

SumMerge merges the element list with new one multiplied by mult

func (Elements) Swap

func (el Elements) Swap(i, j int)

Swap swaps two elements

type LogNode

type LogNode struct {
	Time     time.Time
	Elements Elements
}

LogNode contains log node data

func NewLogNode

func NewLogNode(time time.Time, elements Elements) *LogNode

NewLogNode creates new log node

func NewLogNodeFromElements

func NewLogNodeFromElements(time time.Time, elements Elements) (*LogNode, error)

NewLogNodeFromElements creates new LogNode from ParserNode elements and time

type ParserNode

type ParserNode struct {
	Header   string
	Elements Elements
}

ParserNode contains general node data

func NewParserNode

func NewParserNode(header string) *ParserNode

NewParserNode creates new geneal node

Jump to

Keyboard shortcuts

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