mono
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package mono provides fast monotonic time.On most platforms, mono.Now is about 2x faster than time.Now.However, time.Now is really fast, and nicer to use.
For almost all purposes, you should use time.Now.
Package mono exists because we get the current time multipletimes per network packet, at which point it makes ameasurable difference.
Index¶
- func Since(t Time) time.Duration
- type Time
- func (t Time) Add(d time.Duration) Time
- func (t Time) After(n Time) bool
- func (t Time) Before(n Time) bool
- func (t Time) IsZero() bool
- func (t *Time) LoadAtomic() Time
- func (t Time) MarshalJSON() ([]byte, error)
- func (t *Time) StoreAtomic(new Time)
- func (t Time) String() string
- func (t Time) Sub(n Time) time.Duration
- func (t *Time) UnmarshalJSON(data []byte) error
- func (t Time) WallTime() time.Time
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
Types¶
typeTime¶
type Timeint64
Time is the number of nanoseconds elapsed since an unspecified reference start time.
func (Time)MarshalJSON¶
MarshalJSON formats t for JSON as if it were a time.Time.We format Time this way for backwards-compatibility.Time does not survive a MarshalJSON/UnmarshalJSON round trip unchangedacross different invocations of the Go process. This is best-effort only.Since t is a monotonic time, it can vary from the actual wall clock by arbitrary amounts.Even in the best of circumstances, it may vary by a few milliseconds.
func (*Time)StoreAtomic¶
StoreAtomic does an atomic store *t = new.
func (Time)String¶
String prints t, including an estimated equivalent wall clock.This is best-effort only, for rough debugging purposes only.Since t is a monotonic time, it can vary from the actual wall clock by arbitrary amounts.Even in the best of circumstances, it may vary by a few milliseconds.
func (*Time)UnmarshalJSON¶
UnmarshalJSON sets t according to data.Time does not survive a MarshalJSON/UnmarshalJSON round trip unchangedacross different invocations of the Go process. This is best-effort only.