datatypes

package
v0.0.0-...-cca27e0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Day   = 24 * time.Hour
	Week  = 7 * Day
	Month = 30 * Day
	Year  = 365 * Day
)

Variables

This section is empty.

Functions

func Since

func Since(t *Time) time.Duration

Since returns the time elapsed since t. It is shorthand for time.Now().Sub(t).

func Until

func Until(t *Time) time.Duration

Until returns the duration until t. It is shorthand for t.Sub(time.Now()).

Types

type Bucket

type Bucket struct {
	// contains filtered or unexported fields
}

func NewBucket

func NewBucket(v ...float64) *Bucket

func NewBucket2

func NewBucket2(v ...*float64) *Bucket

func (*Bucket) AVG

func (b *Bucket) AVG() float64

AVG AVG

func (*Bucket) Add

func (b *Bucket) Add(v ...float64)

func (*Bucket) Len

func (b *Bucket) Len() int

func (*Bucket) Less

func (b *Bucket) Less(i, j int) bool

func (*Bucket) MAX

func (b *Bucket) MAX() float64

MAX MAX

func (*Bucket) MED

func (b *Bucket) MED() float64

MED 中位数:Median

func (*Bucket) MIN

func (b *Bucket) MIN() float64

MIN MIN

func (*Bucket) P

func (b *Bucket) P(p float64) float64

func (*Bucket) P90

func (b *Bucket) P90() float64

func (*Bucket) P95

func (b *Bucket) P95() float64

func (*Bucket) P99

func (b *Bucket) P99() float64

func (*Bucket) SUM

func (b *Bucket) SUM() float64

func (*Bucket) Swap

func (b *Bucket) Swap(i, j int)

type CycleList

type CycleList struct {
	// contains filtered or unexported fields
}

CycleList CycleList

func NewCycleList

func NewCycleList(max int) *CycleList

NewCycleList create new cycleList

func (*CycleList) Append

func (c *CycleList) Append(v string)

Append one value

func (*CycleList) List

func (c *CycleList) List() []string

List dump List

type Histogram

type Histogram struct {
	Le []float64
	// contains filtered or unexported fields
}

func NewHistogram

func NewHistogram(le ...float64) *Histogram

func (*Histogram) Compute

func (his *Histogram) Compute(value float64)

type Line

type Line []*float64

Line Line

func NewLine

func NewLine(p ...float64) Line

func (Line) Cut

func (v Line) Cut(check func(v *float64) bool) Line

Cut 去除尾部的无效值,check函数判断是否有效,有效=true,无效=false

func (Line) PointAt

func (v Line) PointAt(startAt *Time, index, period int) *Time

PointAt PointAt

func (Line) RangeMatch

func (v Line) RangeMatch(check func(v *float64) bool, minRange int) [][]int

RangeMatch 设置一个条件, 统计连续满足改条件的数据范围取值有哪些 check函数判断是否有效,有效=true,无效=false minRange int 最小的持续区间

func (Line) String

func (v Line) String() string

String String

type List

type List []string

List defiend JSON data type, need to implements driver.Valuer, sql.Scanner interface

func (List) GormDataType

func (List) GormDataType() string

GormDataType gorm common data type

func (List) MarshalJSON

func (m List) MarshalJSON() ([]byte, error)

MarshalJSON to output non base64 encoded []byte

func (*List) Scan

func (m *List) Scan(v interface{}) error

Scan scan value into Jsonb, implements sql.Scanner interface

func (*List) UnmarshalJSON

func (m *List) UnmarshalJSON(b []byte) error

UnmarshalJSON to deserialize []byte

func (List) Value

func (m List) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type M

type M map[string]interface{}

M defiend JSON data type, need to implements driver.Valuer, sql.Scanner interface

func (M) GormDataType

func (M) GormDataType() string

GormDataType gorm common data type

func (M) Map

func (m M) Map() map[string]interface{}

Map map

func (M) MarshalJSON

func (m M) MarshalJSON() ([]byte, error)

MarshalJSON to output non base64 encoded []byte

func (*M) Scan

func (m *M) Scan(v interface{}) error

Scan scan value into Jsonb, implements sql.Scanner interface

func (*M) UnmarshalJSON

func (m *M) UnmarshalJSON(b []byte) error

UnmarshalJSON to deserialize []byte

func (M) Value

func (m M) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type Set

type Set struct {
	// contains filtered or unexported fields
}

Set set

func NewSet

func NewSet(vs ...string) *Set

NewSet new set

func (*Set) Append

func (s *Set) Append(vs ...string) *Set

Append append

func (*Set) Contains

func (s *Set) Contains(v string) bool

Contains contains

func (*Set) Len

func (s *Set) Len() int

Len len

func (*Set) List

func (s *Set) List() []string

List list

func (*Set) Remove

func (s *Set) Remove(vs ...string) *Set

type Time

type Time time.Time

Time time: 2006-01-02 15:04:05

func Date

func Date(year int, month time.Month, day, hour, min, sec, nsec int, loc *time.Location) *Time

Date returns the Time corresponding to

func FromTimestamp

func FromTimestamp(ts int64) *Time

func NewTime

func NewTime(t time.Time, layout ...string) *Time

NewTime newTime

func Now

func Now() *Time

Now now

func Parse

func Parse(layout, value string) (*Time, error)

Parse parses a formatted string and returns the time value it represents. The layout defines the format by showing )how the reference time, defined to be

func ParseInLocation

func ParseInLocation(layout, value string, loc *time.Location) (*Time, error)

ParseInLocation is like Parse but differs in two important ways. First, in the absence of time zone information, Parse interprets a time as UTC; ParseInLocation interprets the time as in the given location. Second, when given a zone offset or abbreviation, Parse tries to match it against the Local location; ParseInLocation uses the given location.

func (*Time) Add

func (t *Time) Add(d time.Duration) *Time

Add returns the time t+d.

func (*Time) AddDate

func (t *Time) AddDate(years int, months int, days int) *Time

AddDate returns the time corresponding to adding the given number of years, months, and days to t. For example, AddDate(-1, 2, 3) applied to January 1, 2011 returns March 4, 2010. AddDate normalizes its result in the same way that Date does, so, for example, adding one month to October 31 yields December 1, the normalized form for November 31.

func (*Time) After

func (t *Time) After(u *Time) bool

After reports whether the time instant t is after u.

func (*Time) Before

func (t *Time) Before(u *Time) bool

Before reports whether the time instant t is before u.

func (*Time) Clock

func (t *Time) Clock() (hour, min, sec int)

Clock returns the hour, minute, and second within the day specified by t.

func (*Time) Date

func (t *Time) Date() (year int, month time.Month, day int)

Date returns the year, month, and day in which t occurs.

func (*Time) Day

func (t *Time) Day() int

Day returns the day of the month specified by t.

func (*Time) Equal

func (t *Time) Equal(u *Time) bool

Equal reports whether t and u represent the same time instant. Two times can be equal even if they are in different locations. For example, 6:00 +0200 and 4:00 UTC are Equal. See the documentation on the Time type for the pitfalls of using == with Time values; most code should use Equal instead.

func (*Time) Format

func (t *Time) Format(layout string) string

Format returns a textual representation of the time value formatted according to layout, which defines the format by showing how the reference time, defined to be

func (*Time) Hour

func (t *Time) Hour() int

Hour returns the hour within the day specified by t, in the range [0, 23].

func (*Time) IsZero

func (t *Time) IsZero() bool

IsZero isZero

func (*Time) Location

func (t *Time) Location() *time.Location

Location returns the time zone information associated with t.

func (Time) MarshalBinary

func (t Time) MarshalBinary() ([]byte, error)

MarshalBinary implement encoding.BinaryMarshaler.

func (*Time) MarshalJSON

func (t *Time) MarshalJSON() ([]byte, error)

MarshalJSON marshaler interface

func (*Time) Minute

func (t *Time) Minute() int

Minute returns the minute offset within the hour specified by t, in the range [0, 59].

func (*Time) Month

func (t *Time) Month() time.Month

Month returns the month of the year specified by t.

func (*Time) Nanosecond

func (t *Time) Nanosecond() int

Nanosecond returns the nanosecond offset within the second specified by t, in the range [0, 999999999].

func (*Time) Scan

func (t *Time) Scan(v interface{}) error

Scan scan value into Jsonb, implements sql.Scanner interface

func (*Time) Second

func (t *Time) Second() int

Second returns the second offset within the minute specified by t, in the range [0, 59].

func (*Time) String

func (t *Time) String() string

String returns the time formatted using the format string

func (*Time) Sub

func (t *Time) Sub(u *Time) time.Duration

Sub returns the duration t-u. If the result exceeds the maximum (or minimum) value that can be stored in a Duration, the maximum (or minimum) duration will be returned. To compute t-d for a duration d, use t.Add(-d).

func (*Time) Time

func (t *Time) Time() time.Time

Time time

func (*Time) Timestamp

func (t *Time) Timestamp() int64

Timestamp returns a new millisecond timestamp from a time.

func (*Time) Truncate

func (t *Time) Truncate(d time.Duration) *Time

Truncate returns a new time with the time truncated to the given number of seconds.

func (*Time) UTC

func (t *Time) UTC() *Time

UTC returns t with the location set to UTC.

func (*Time) Unix

func (t *Time) Unix() int64

Unix unix

func (*Time) UnmarshalBinary

func (t *Time) UnmarshalBinary(b []byte) error

UnmarshalBinary implement encoding.BinaryUnmarshaler.

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshaler interface

func (*Time) Value

func (t *Time) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

func (*Time) Weekday

func (t *Time) Weekday() time.Weekday

Weekday returns the day of the week specified by t.

func (*Time) Year

func (t *Time) Year() int

Year returns the year in which t occurs.

type Timestamp

type Timestamp int64

func (*Timestamp) MarshalBinary

func (ts *Timestamp) MarshalBinary() ([]byte, error)

func (*Timestamp) Scan

func (ts *Timestamp) Scan(v interface{}) error

Scan scan value into Jsonb, implements sql.Scanner interface

func (*Timestamp) Time

func (ts *Timestamp) Time() *Time

func (*Timestamp) UnmarshalBinary

func (ts *Timestamp) UnmarshalBinary(b []byte) error

UnmarshalBinary implement encoding.BinaryUnmarshaler.

func (*Timestamp) Value

func (ts *Timestamp) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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