Documentation ¶
Index ¶
- Constants
- func Compare(c1, c2 context.Context) context.Context
- func HumanDurationFormat(stamp int64, designation ...time.Time) string
- func Shrink(c context.Context, d time.Duration) (time.Duration, context.Context, context.CancelFunc)
- type DTime
- type Date
- type DateStruct
- func (m *DateStruct) GormDataType() string
- func (m *DateStruct) MarshalJSON() ([]byte, error)
- func (m *DateStruct) Scan(value interface{}) error
- func (m *DateStruct) String() string
- func (m *DateStruct) ToDateTime() *DateTimeStruct
- func (m *DateStruct) UnmarshalJSON(src []byte) error
- func (m *DateStruct) UnmarshalText(value string) error
- func (m *DateStruct) UnmarshalTextByLayout(layout, value string) error
- func (m *DateStruct) Value() (driver.Value, error)
- type DateTime
- func (DateTime) GormDataType() string
- func (d DateTime) MarshalJSON() ([]byte, error)
- func (d *DateTime) Scan(value interface{}) error
- func (d DateTime) String() string
- func (d *DateTime) UnmarshalJSON(src []byte) error
- func (d *DateTime) UnmarshalText(value string) error
- func (d DateTime) Value() (driver.Value, error)
- type DateTimeStruct
- func (m *DateTimeStruct) GormDataType() string
- func (m *DateTimeStruct) MarshalJSON() ([]byte, error)
- func (m *DateTimeStruct) Scan(value interface{}) error
- func (m *DateTimeStruct) String() string
- func (m *DateTimeStruct) ToDate() *DateStruct
- func (m *DateTimeStruct) UnmarshalJSON(src []byte) error
- func (m *DateTimeStruct) UnmarshalText(value string) error
- func (m *DateTimeStruct) UnmarshalTextByLayout(layout, value string) error
- func (m *DateTimeStruct) Value() (driver.Value, error)
- type DbJSON
- func (j *DbJSON) Get(obj interface{}) error
- func (DbJSON) GormDataType() string
- func (j DbJSON) MarshalJSON() ([]byte, error)
- func (j *DbJSON) Scan(value interface{}) error
- func (j *DbJSON) Set(obj interface{}) (err error)
- func (j *DbJSON) UnmarshalJSON(src []byte) (err error)
- func (j *DbJSON) UnmarshalText(value string) error
- func (j DbJSON) Value() (driver.Value, error)
- type Stamp
Examples ¶
Constants ¶
const DTimeFormat = "15:04:05"
const DateFormat = "2006-01-02"
const DateTimeFormat = "2006-01-02 15:04:05"
Variables ¶
This section is empty.
Functions ¶
func Shrink ¶
func Shrink(c context.Context, d time.Duration) (time.Duration, context.Context, context.CancelFunc)
Shrink 用于链路超时时间以及当前节点的超时时间控制
Example ¶
// timeout.Shrink 方法提供全链路的超时控制 // 只需要传入一个父节点的ctx 和需要设置的超时时间,他会帮你确认这个ctx是否之前设置过超时时间, // 如果设置过超时时间的话会和你当前设置的超时时间进行比较,选择一个最小的进行设置,保证链路超时时间不会被下游影响 // d: 代表剩余的超时时间 // nCtx: 新的context对象 // cancel: 如果是成功真正设置了超时时间会返回一个cancel()方法,未设置成功会返回一个无效的cancel,不过别担心,还是可以正常调用的 d, nCtx, cancel := Shrink(context.Background(), 5*time.Second) // d 根据需要判断 // 一般判断该服务的下游超时时间,如果d过于小,可以直接放弃 select { case <-nCtx.Done(): cancel() default: // ... } _ = d
Output:
Types ¶
type DTime ¶
func (DTime) GormDataType ¶
func (DTime) MarshalJSON ¶
func (*DTime) UnmarshalJSON ¶
func (*DTime) UnmarshalText ¶
type Date ¶
func (Date) GormDataType ¶
func (Date) MarshalJSON ¶
func (*Date) UnmarshalJSON ¶
func (*Date) UnmarshalText ¶
type DateStruct ¶
func (*DateStruct) GormDataType ¶
func (m *DateStruct) GormDataType() string
GormDataType gorm 定义数据库字段类型 Author [SliverHorn](https://github.com/SliverHorn)
func (*DateStruct) MarshalJSON ¶
func (m *DateStruct) MarshalJSON() ([]byte, error)
MarshalJSON 序列化 Author [SliverHorn](https://github.com/SliverHorn)
func (*DateStruct) Scan ¶
func (m *DateStruct) Scan(value interface{}) error
Scan 扫描 Author [SliverHorn](https://github.com/SliverHorn)
func (*DateStruct) String ¶
func (m *DateStruct) String() string
String 输出 DateTime 变量为字符串 Author [SliverHorn](https://github.com/SliverHorn)
func (*DateStruct) ToDateTime ¶
func (m *DateStruct) ToDateTime() *DateTimeStruct
ToDateTime Date to Datetime Author [SliverHorn](https://github.com/SliverHorn)
func (*DateStruct) UnmarshalJSON ¶
func (m *DateStruct) UnmarshalJSON(src []byte) error
UnmarshalJSON 反序列化 Author [SliverHorn](https://github.com/SliverHorn)
func (*DateStruct) UnmarshalText ¶
func (m *DateStruct) UnmarshalText(value string) error
UnmarshalText 通过 string 序列化成 Date Author [SliverHorn](https://github.com/SliverHorn)
func (*DateStruct) UnmarshalTextByLayout ¶
func (m *DateStruct) UnmarshalTextByLayout(layout, value string) error
UnmarshalTextByLayout 通过 string 序列化成 Date by layout Author [SliverHorn](https://github.com/SliverHorn)
func (*DateStruct) Value ¶
func (m *DateStruct) Value() (driver.Value, error)
Value 值 Author [SliverHorn](https://github.com/SliverHorn)
type DateTime ¶
func (DateTime) GormDataType ¶
func (DateTime) MarshalJSON ¶
func (*DateTime) UnmarshalJSON ¶
func (*DateTime) UnmarshalText ¶
type DateTimeStruct ¶
func (*DateTimeStruct) GormDataType ¶
func (m *DateTimeStruct) GormDataType() string
GormDataType gorm 定义数据库字段类型 Author [SliverHorn](https://github.com/SliverHorn)
func (*DateTimeStruct) MarshalJSON ¶
func (m *DateTimeStruct) MarshalJSON() ([]byte, error)
MarshalJSON 序列化 Author [SliverHorn](https://github.com/SliverHorn)
func (*DateTimeStruct) Scan ¶
func (m *DateTimeStruct) Scan(value interface{}) error
Scan 扫描 Author [SliverHorn](https://github.com/SliverHorn)
func (*DateTimeStruct) String ¶
func (m *DateTimeStruct) String() string
String 输出 DateTime 变量为字符串 Author [SliverHorn](https://github.com/SliverHorn)
func (*DateTimeStruct) ToDate ¶
func (m *DateTimeStruct) ToDate() *DateStruct
ToDate DateTime 2 Date Author [SliverHorn](https://github.com/SliverHorn)
func (*DateTimeStruct) UnmarshalJSON ¶
func (m *DateTimeStruct) UnmarshalJSON(src []byte) error
UnmarshalJSON 反序列化 Author [SliverHorn](https://github.com/SliverHorn)
func (*DateTimeStruct) UnmarshalText ¶
func (m *DateTimeStruct) UnmarshalText(value string) error
UnmarshalText 通过 string 反序列化成 DateTime Author [SliverHorn](https://github.com/SliverHorn)
func (*DateTimeStruct) UnmarshalTextByLayout ¶
func (m *DateTimeStruct) UnmarshalTextByLayout(layout, value string) error
UnmarshalTextByLayout 通过 string 序列化成 DateTime Author [SliverHorn](https://github.com/SliverHorn)
func (*DateTimeStruct) Value ¶
func (m *DateTimeStruct) Value() (driver.Value, error)
Value 值 Author [SliverHorn](https://github.com/SliverHorn)
type DbJSON ¶
type DbJSON []byte
func DBJSONFromObject ¶
func DBJSONFromObject(obj interface{}) DbJSON