shared

package module
v0.0.0-...-78da9ed Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2014 License: MIT Imports: 2 Imported by: 11

README

shared Build Status

Shared types across the Hranoprovod projects

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 Element

type Element struct {
	Name string
	Val  float32
}

Element contains single element data

func NewElement

func NewElement(name string, val float32) *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 float32)

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, coef float32)

SumMerge merges the element list with new one multiplied by coef

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 NewLogNodeFromNode

func NewLogNodeFromNode(node *Node, dateFormat string) (*LogNode, error)

NewLogNodeFromNode creates new LogNode from Node

type Node

type Node struct {
	Header   string
	Elements *Elements
}

Node contains general node data

func NewNode

func NewNode(header string) *Node

NewNode creates new geneal node

type NodeList

type NodeList map[string]*Node

NodeList contains list of general nodes

func NewNodeList

func NewNodeList() *NodeList

NewNodeList creates new list of general nodes

func (*NodeList) Push

func (db *NodeList) Push(node *Node)

Push adds node to the node list

Jump to

Keyboard shortcuts

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