Documentation ¶
Overview ¶
Package cm (common) provides most used elements.
Index ¶
- func IsZeroTime(t time.Time) bool
- func Millis(t time.Time) int64
- type IntID
- type Timestamp
- func (t Timestamp) Add(d time.Duration) Timestamp
- func (t Timestamp) AddDays(days int) Timestamp
- func (t Timestamp) After(u Timestamp) bool
- func (t Timestamp) Before(u Timestamp) bool
- func (t Timestamp) IsZero() bool
- func (t Timestamp) MarshalJSON() ([]byte, error)
- func (t Timestamp) Millis() int64
- func (t Timestamp) String() string
- func (t Timestamp) Sub(u Timestamp) time.Duration
- func (t Timestamp) ToTime() time.Time
- func (t Timestamp) Unix() int64
- func (t Timestamp) UnixNano() int64
- func (t *Timestamp) UnmarshalJSON(b []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsZeroTime ¶
IsZeroTime checks whether given time is zero. When transport time using grpc, empty time is marshalled to time.Unix(0, 0).
Types ¶
type IntID ¶
type IntID int64
func NewIntID ¶
func NewIntID() IntID
NewIntID mocks generating new id. In production, we need to use a more robust function.
func (IntID) MarshalJSON ¶
func (*IntID) UnmarshalJSON ¶
type Timestamp ¶
type Timestamp int64
Timestamp represents time as number of milliseconds from 1970.
func ToTimestamp ¶
ToTimestamp converts from Go time to timestamp (in nanosecond).
func (Timestamp) MarshalJSON ¶
MarshalJSON implements JSONMarshaler
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON implements JSONUnmarshaler
Click to show internal directories.
Click to hide internal directories.