Documentation ¶
Index ¶
- Constants
- func Atof(v string, d float64) float64
- func Atoi(v string, d int) int
- func Atoi64(v string, d int64) int64
- func Clone(ctx context.Context, source interface{}, target interface{}) (err error)
- func FormatLayout(layout string) string
- func FormatTime(t *time.Time, format string) string
- func Ftoa(v float64) string
- func IsEmpty(s string) bool
- func IsNotEmpty(s string) bool
- func LastString(s string, num int) string
- func Now(offset int) time.Time
- func PadLeft(s string, lenght int, char string) string
- func ParseTime(v string, layout string, d *time.Time) *time.Time
- func Round32(val float32, roundOn float32, places int) (newVal float32)
- func Round64(val float64, roundOn float64, places int) (newVal float64)
- func SwitchTimezone(t time.Time, offset int) time.Time
- func ToInt(v interface{}, defaultValue int) int
- func ToString(v interface{}, defaultValue string) string
- func Today(offset int) time.Time
- func WithContext(ctx context.Context, app Context) context.Context
- type Binder
- type Boolean
- func (f *Boolean) GetValue() bool
- func (b Boolean) MarshalJSON() ([]byte, error)
- func (f *Boolean) Ptr() *bool
- func (b *Boolean) Scan(value interface{}) error
- func (f *Boolean) SetValue(i bool)
- func (f Boolean) String() string
- func (b *Boolean) UnmarshalJSON(data []byte) error
- func (b Boolean) Value() (driver.Value, error)
- type Cloner
- type Context
- type Contexter
- type Field
- type Float32
- func (f *Float32) GetValue() float32
- func (f Float32) MarshalJSON() ([]byte, error)
- func (f *Float32) Ptr() *float32
- func (f *Float32) Scan(value interface{}) error
- func (f *Float32) SetValue(i float32)
- func (f Float32) String() string
- func (f *Float32) UnmarshalJSON(data []byte) error
- func (f Float32) Value() (driver.Value, error)
- type Float64
- func (f *Float64) GetValue() float64
- func (f Float64) MarshalJSON() ([]byte, error)
- func (f *Float64) Ptr() *float64
- func (f *Float64) Scan(value interface{}) error
- func (f *Float64) SetValue(i float64)
- func (f Float64) String() string
- func (f *Float64) UnmarshalJSON(data []byte) error
- func (f Float64) Value() (driver.Value, error)
- type Form
- func (m *Form) Add(key, value string) *Form
- func (m *Form) AddJSON(key, value string, quote bool) *Form
- func (m *Form) EncodeURL() string
- func (m *Form) Get(key string) string
- func (m *Form) Join(sep string) string
- func (m *Form) JoinAll(sep string) string
- func (m *Form) JoinFunc(each func(key, value string) (string, bool), sep string, sortFirst bool) string
- func (m *Form) JoinValues(sep string) string
- func (m *Form) SortAndJoin(sep string) string
- func (m *Form) SortAndJoinAll(sep string) string
- func (m *Form) ToForm() map[string]string
- func (m *Form) ToJSON() string
- func (m *Form) Update(key, value string, quote bool) *Form
- type Int
- type Int32
- func (f *Int32) GetValue() int32
- func (f Int32) MarshalJSON() ([]byte, error)
- func (f *Int32) Ptr() *int32
- func (f *Int32) Scan(value interface{}) error
- func (f *Int32) SetValue(i int32)
- func (f Int32) String() string
- func (f *Int32) UnmarshalJSON(data []byte) error
- func (f Int32) Value() (driver.Value, error)
- type Int64
- func (f *Int64) GetValue() int64
- func (f Int64) MarshalJSON() ([]byte, error)
- func (f *Int64) Ptr() *int64
- func (f *Int64) Scan(value interface{}) error
- func (f *Int64) SetValue(i int64)
- func (f Int64) String() string
- func (f *Int64) UnmarshalJSON(data []byte) error
- func (f Int64) Value() (driver.Value, error)
- type Object
- type String
- func (s *String) GetValue() string
- func (s *String) HasValue() bool
- func (s *String) IsNull() bool
- func (s String) MarshalJSON() ([]byte, error)
- func (s *String) Ptr() *string
- func (s *String) Scan(value interface{}) error
- func (s *String) SetValue(v string)
- func (s String) String() string
- func (s *String) UnmarshalJSON(data []byte) error
- func (s String) Value() (driver.Value, error)
- type StringBuilder
- type Time
- func (t *Time) GetValue() time.Time
- func (t *Time) IsNull() bool
- func (t *Time) MarshalBSON() ([]byte, error)
- func (t Time) MarshalJSON() ([]byte, error)
- func (t *Time) Ptr() *time.Time
- func (t *Time) Scan(value interface{}) (err error)
- func (t *Time) SetContext(ctx context.Context)
- func (t *Time) SetValue(v time.Time)
- func (t Time) String() string
- func (t *Time) UnmarshalBSON(data []byte) error
- func (t *Time) UnmarshalJSON(data []byte) error
- func (t Time) Value() (driver.Value, error)
Constants ¶
const ( //TimeLongMonth long format of month TimeLongMonth = "January" //TimeMonth format of month TimeMonth = "Jan" //TimeNumMonth number format of month TimeNumMonth = "1" //TimeZeroMonth zero format of month TimeZeroMonth = "01" //TimeLongWeekDay long format of weekday TimeLongWeekDay = "Monday" //TimeWeekDay format of weekday TimeWeekDay = "Mon" //TimeDay format of day TimeDay = "2" //TimeZeroDay zero format of day TimeZeroDay = "02" //TimeHour24 24 hours format of hour TimeHour24 = "15" //TimeHour12 12 hours format of hour TimeHour12 = "3" //TimeZeroHour12 12 hours zero format of hour TimeZeroHour12 = "03" //TimeMinute format of minute TimeMinute = "4" //TimeZeroMinute zero format of minute TimeZeroMinute = "04" //TimeSecond format of second TimeSecond = "5" //TimeZeroSecond zero format of second TimeZeroSecond = "05" //TimeLongYear long format of year TimeLongYear = "2006" //TimeYear format of year TimeYear = "06" //TimePM format of PM TimePM = "PM" //Timepm format of pm Timepm = "pm" //TimeTZ MST TimeTZ = "MST" //TimeISO8601TZ ISO8601TZ TimeISO8601TZ = "Z0700" // prints Z for UTC //TimeISO8601SecondsTZ ISO8601SecondsTZ TimeISO8601SecondsTZ = "Z070000" //TimeISO8601ShortTZ ISO8601ShortTZ TimeISO8601ShortTZ = "Z07" //TimeISO8601ColonTZ ISO8601ColonTZ TimeISO8601ColonTZ = "Z07:00" // prints Z for UTC //TimeISO8601ColonSecondsTZ ISO8601ColonSecondsTZ TimeISO8601ColonSecondsTZ = "Z07:00:00" //TimeNumTZ NumTZ TimeNumTZ = "-0700" // always numeric //TimeNumSecondsTz NumSecondsTz TimeNumSecondsTz = "-070000" //TimeNumShortTZ NumShortTZ TimeNumShortTZ = "-07" // always numeric //TimeNumColonTZ NumColonTZ TimeNumColonTZ = "-07:00" // always numeric //TimeNumColonSecondsTZ NumColonSecondsTZ TimeNumColonSecondsTZ = "-07:00:00" )
const ( //TimeFormatDateTime yyyyMMDDHHmmSS TimeFormatDateTime = TimeLongYear + TimeZeroMonth + TimeZeroDay + TimeHour24 + TimeZeroMinute + TimeZeroSecond //TimeFormatDateTimeWithDash yyyy-MM-DD HH:mm:ss TimeFormatDateTimeWithDash = TimeLongYear + "-" + TimeZeroMonth + "-" + TimeZeroDay + " " + TimeHour24 + ":" + TimeZeroMinute + ":" + TimeZeroSecond )
Variables ¶
This section is empty.
Functions ¶
func FormatLayout ¶
FormatLayout convert RFC layout to golang magic time number
func FormatTime ¶
FormatTime format time with special format, eg. YYYY-MM-dd HH:mm:ss
func IsNotEmpty ¶
IsNotEmpty return true if string has valid value, else true
func LastString ¶
LastString return last num char as string
func Round32 ¶
Round32 round float64 value https://gist.github.com/DavidVaini/10308388
func Round64 ¶
Round64 round float64 value https://gist.github.com/DavidVaini/10308388
func SwitchTimezone ¶
SwitchTimezone convert timezone
Types ¶
type Binder ¶
type Binder interface { //Bind 自動綁定數據到對應到欄位上 Bind(ctx context.Context, data map[string]string) error }
Binder 物件綁定器
type Boolean ¶
type Boolean struct {
// contains filtered or unexported fields
}
Boolean bool wrapper
func NewBoolean ¶
func (Boolean) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Boolean) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports string and null input. Blank string input does not produce a null String. It also supports unmarshalling a sql.NullString.
type Context ¶
type Context struct { RequestID int AcceptLanuage string TimeOffset int TimeJSON string TimeLayout string }
Context a request-scope context
type Float32 ¶
type Float32 struct {
// contains filtered or unexported fields
}
Float32 float32 wrapper
func NewFloat32 ¶
func (Float32) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Float32) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports string and null input. Blank string input does not produce a null String. It also supports unmarshalling a sql.NullString.
type Float64 ¶
type Float64 struct {
// contains filtered or unexported fields
}
Float64 float64 wrapper
func NewFloat64 ¶
func (Float64) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Float64) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports string and null input. Blank string input does not produce a null String. It also supports unmarshalling a sql.NullString.
type Form ¶
Form 表单
func (*Form) JoinFunc ¶
func (m *Form) JoinFunc(each func(key, value string) (string, bool), sep string, sortFirst bool) string
JoinFunc 自定义拼接
func (*Form) JoinValues ¶
JoinValues 按字段加入顺序,按指定字符做拼接字段值,空值忽略
func (*Form) SortAndJoin ¶
SortAndJoin 按字段名排序并且按指定字符做拼接“字段名称=字段值”,空值忽略
func (*Form) SortAndJoinAll ¶
SortAndJoinAll 按字段名排序并且按指定字符做拼接“字段名称=字段值”,空值不忽略
type Int ¶
type Int struct {
// contains filtered or unexported fields
}
Int int wrapper
func (Int) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Int) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports string and null input. Blank string input does not produce a null String. It also supports unmarshalling a sql.NullString.
type Int32 ¶
type Int32 struct {
// contains filtered or unexported fields
}
Int32 int32 wrapper
func (Int32) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Int32) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports string and null input. Blank string input does not produce a null String. It also supports unmarshalling a sql.NullString.
type Int64 ¶
type Int64 struct {
// contains filtered or unexported fields
}
Int64 int64 wrapper
func (Int64) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Int64) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports string and null input. Blank string input does not produce a null String. It also supports unmarshalling a sql.NullString.
type String ¶
type String struct {
// contains filtered or unexported fields
}
String string wrapper
func (String) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*String) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports string and null input. Blank string input does not produce a null String. It also supports unmarshalling a sql.NullString.
type StringBuilder ¶
StringBuilder 包裝strings.Builder提供便利的操作函式庫
func (*StringBuilder) AppendLine ¶
func (sb *StringBuilder) AppendLine(args ...interface{}) *StringBuilder
AppendLine 增加行
func (*StringBuilder) AppendLinef ¶
func (sb *StringBuilder) AppendLinef(format string, args ...interface{}) *StringBuilder
AppendLinef 增加行
type Time ¶
Time time wrapper
func (*Time) MarshalBSON ¶
func (Time) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Time) SetContext ¶
SetContext implements Object.SetContext
func (*Time) UnmarshalBSON ¶
func (*Time) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports string and null input. Blank string input does not produce a null String. It also supports unmarshalling a sql.NullString.
Source Files ¶
- binder.go
- bool.go
- bool_json.go
- bool_sql.go
- cloner.go
- context.go
- float32.go
- float32_json.go
- float32_sql.go
- float64.go
- float64_json.go
- float64_sql.go
- float_helper.go
- form.go
- int.go
- int32.go
- int32_json.go
- int32_sql.go
- int64.go
- int64_json.go
- int64_sql.go
- int_helper.go
- int_json.go
- int_sql.go
- object.go
- string.go
- string_helper.go
- string_json.go
- string_sql.go
- stringbuilder.go
- time.go
- time_bson.go
- time_helper.go
- time_json.go
- time_sql.go