util

package
v0.0.0-...-f2f702e Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2019 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDivideByZero error
	ErrDivideByZero = errors.New("cannot divide by zero")
)

Functions

func CompareHashAndPassword

func CompareHashAndPassword(input, hash string) error

CompareHashAndPassword compares input with hash, returns error if any

func Contains

func Contains(a []int, x int) bool

Contains func

func ConvertTimeStampToString

func ConvertTimeStampToString(timestamp time.Time) string

ConvertTimeStampToString converts date to string for inserting in db

func DatetimeLocalToRFC3339

func DatetimeLocalToRFC3339(str string) (time.Time, error)

DatetimeLocalToRFC3339 converts a string from datetime-local HTML input-field to time.Time object

func GenerateFromPassword

func GenerateFromPassword(input string) (string, error)

GenerateFromPassword returns hashed string with cost 14

func GetTimeInCorrectTimeZone

func GetTimeInCorrectTimeZone() time.Time

GetTimeInCorrectTimeZone returns the time in "TIME_ZONE" time

func GoToHTMLDatetimeLocal

func GoToHTMLDatetimeLocal(t time.Time) string

GoToHTMLDatetimeLocal converts time.Time object to 'datetime-local' in HTML

func ShuffleIntSlice

func ShuffleIntSlice(slice []int) []int

ShuffleIntSlice func

Types

type Statistics

type Statistics struct {
	Entries []float64
	AbsMin  float64
	AbsMax  float64
}

Statistics struct

func NewStatistics

func NewStatistics(min, max float64) *Statistics

NewStatistics func

func (*Statistics) AddEntry

func (s *Statistics) AddEntry(entry float64)

AddEntry adds new entry to the slice of entries

func (Statistics) Average

func (s Statistics) Average() (float64, error)

Average value of the all the entries

func (Statistics) AveragePercent

func (s Statistics) AveragePercent() (float64, error)

AveragePercent of all entries based on a set absolute max

func (Statistics) GetDisplayStruct

func (s Statistics) GetDisplayStruct() StatisticsDisplay

GetDisplayStruct returns a struct for displaying the data

func (Statistics) Max

func (s Statistics) Max() float64

Max func

func (Statistics) Min

func (s Statistics) Min() float64

Min func

func (Statistics) Size

func (s Statistics) Size() int

Size of the entries slice

func (Statistics) StandardDeviation

func (s Statistics) StandardDeviation() (float64, error)

StandardDeviation func

func (Statistics) Sum

func (s Statistics) Sum() float64

Sum up all entries

func (Statistics) Variance

func (s Statistics) Variance() (float64, error)

Variance func

type StatisticsDisplay

type StatisticsDisplay struct {
	Average           float64
	Variance          float64
	StandardDeviation float64
	Percent           float64
	AbsMin            float64
	AbsMax            float64
	LocalMin          float64
	LocalMax          float64
	Entries           int
}

StatisticsDisplay struct

Jump to

Keyboard shortcuts

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