types

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
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 Atof

func Atof(v string, d float64) float64

Atof covert string value to float with default value

func Atoi

func Atoi(v string, d int) int

Atoi convert string to int

func Atoi64

func Atoi64(v string, d int64) int64

Atoi64 convert string to int64

func Clone

func Clone(ctx context.Context, source interface{}, target interface{}) (err error)

Clone 複製物件數據

func FormatLayout

func FormatLayout(layout string) string

FormatLayout convert RFC layout to golang magic time number

func FormatTime

func FormatTime(t *time.Time, format string) string

FormatTime format time with special format, eg. YYYY-MM-dd HH:mm:ss

func Ftoa

func Ftoa(v float64) string

Ftoa covert float64 value to string with default round

func IsEmpty

func IsEmpty(s string) bool

IsEmpty return true if string has no any valid value, else true

func IsNotEmpty

func IsNotEmpty(s string) bool

IsNotEmpty return true if string has valid value, else true

func LastString

func LastString(s string, num int) string

LastString return last num char as string

func Now

func Now(offset int) time.Time

Now 获取指定时区的当前时间

func PadLeft

func PadLeft(s string, lenght int, char string) string

PadLeft x

func ParseTime

func ParseTime(v string, layout string, d *time.Time) *time.Time

ParseTime try to parse string with specified layout, if not, return d

func Round32

func Round32(val float32, roundOn float32, places int) (newVal float32)

Round32 round float64 value https://gist.github.com/DavidVaini/10308388

func Round64

func Round64(val float64, roundOn float64, places int) (newVal float64)

Round64 round float64 value https://gist.github.com/DavidVaini/10308388

func SwitchTimezone

func SwitchTimezone(t time.Time, offset int) time.Time

SwitchTimezone convert timezone

func ToInt

func ToInt(v interface{}, defaultValue int) int

ToInt try convert object to int

func ToString

func ToString(v interface{}, defaultValue string) string

ToString try convert object to string

func Today

func Today(offset int) time.Time

Today 获取指定时区的今天零点

func WithContext

func WithContext(ctx context.Context, app Context) context.Context

WithContext 置入程序上下文对象

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 NewBoolean(val bool) Boolean

func (*Boolean) GetValue

func (f *Boolean) GetValue() bool

GetValue return bool value

func (Boolean) MarshalJSON

func (b Boolean) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Boolean) Ptr

func (f *Boolean) Ptr() *bool

Ptr return pobool value

func (*Boolean) Scan

func (b *Boolean) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

func (*Boolean) SetValue

func (f *Boolean) SetValue(i bool)

SetValue set bool value

func (Boolean) String

func (f Boolean) String() string

String implements Stringer

func (*Boolean) UnmarshalJSON

func (b *Boolean) UnmarshalJSON(data []byte) error

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.

func (Boolean) Value

func (b Boolean) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type Cloner

type Cloner interface {
	Clone(ctx context.Context, target interface{}) error
}

Cloner 物件複製器

type Context

type Context struct {
	RequestID int

	AcceptLanuage string

	TimeOffset int
	TimeJSON   string
	TimeLayout string
}

Context a request-scope context

func FromContext

func FromContext(ctx context.Context) Context

FromContext 提取程序上下文

type Contexter

type Contexter interface {
	SetContext(ctx context.Context)
}

Contexter an object which accepts context

type Field

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

Field 表单字段

type Float32

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

Float32 float32 wrapper

func NewFloat32

func NewFloat32(val float32) Float32

func (*Float32) GetValue

func (f *Float32) GetValue() float32

GetValue return float32 value

func (Float32) MarshalJSON

func (f Float32) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Float32) Ptr

func (f *Float32) Ptr() *float32

Ptr return point value

func (*Float32) Scan

func (f *Float32) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

func (*Float32) SetValue

func (f *Float32) SetValue(i float32)

SetValue set float32 value

func (Float32) String

func (f Float32) String() string

String implements Stringer

func (*Float32) UnmarshalJSON

func (f *Float32) UnmarshalJSON(data []byte) error

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.

func (Float32) Value

func (f Float32) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type Float64

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

Float64 float64 wrapper

func NewFloat64

func NewFloat64(val float64) Float64

func (*Float64) GetValue

func (f *Float64) GetValue() float64

GetValue return Float64 value

func (Float64) MarshalJSON

func (f Float64) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Float64) Ptr

func (f *Float64) Ptr() *float64

Ptr return point value

func (*Float64) Scan

func (f *Float64) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

func (*Float64) SetValue

func (f *Float64) SetValue(i float64)

SetValue set Float64 value

func (Float64) String

func (f Float64) String() string

String implements Stringer

func (*Float64) UnmarshalJSON

func (f *Float64) UnmarshalJSON(data []byte) error

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.

func (Float64) Value

func (f Float64) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type Form

type Form struct {
	Keys   []string
	Fields map[string]*Field
}

Form 表单

func NewForm

func NewForm() Form

NewForm 创建Form对象

func (*Form) Add

func (m *Form) Add(key, value string) *Form

Add 添加字段数据

func (*Form) AddJSON

func (m *Form) AddJSON(key, value string, quote bool) *Form

AddJSON 加入JSON字段数据

func (*Form) EncodeURL

func (m *Form) EncodeURL() string

EncodeURL 转成URL编码格式

func (*Form) Get

func (m *Form) Get(key string) string

Get 获取指定名称字段值

func (*Form) Join

func (m *Form) Join(sep string) string

Join 按字段加入顺序,按指定字符做拼接“字段名称=字段值”,空值忽略

func (*Form) JoinAll

func (m *Form) JoinAll(sep string) string

JoinAll 按字段加入顺序,按指定字符做拼接“字段名称=字段值”,空值不忽略

func (*Form) JoinFunc

func (m *Form) JoinFunc(each func(key, value string) (string, bool), sep string, sortFirst bool) string

JoinFunc 自定义拼接

func (*Form) JoinValues

func (m *Form) JoinValues(sep string) string

JoinValues 按字段加入顺序,按指定字符做拼接字段值,空值忽略

func (*Form) SortAndJoin

func (m *Form) SortAndJoin(sep string) string

SortAndJoin 按字段名排序并且按指定字符做拼接“字段名称=字段值”,空值忽略

func (*Form) SortAndJoinAll

func (m *Form) SortAndJoinAll(sep string) string

SortAndJoinAll 按字段名排序并且按指定字符做拼接“字段名称=字段值”,空值不忽略

func (*Form) ToForm

func (m *Form) ToForm() map[string]string

ToForm 转成原始map对象

func (*Form) ToJSON

func (m *Form) ToJSON() string

ToJSON 生成JSON数字串

func (*Form) Update

func (m *Form) Update(key, value string, quote bool) *Form

Update 更新字段值

type Int

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

Int int wrapper

func NewInt

func NewInt(val int) Int

func (*Int) GetValue

func (f *Int) GetValue() int

GetValue return int value

func (Int) MarshalJSON

func (f Int) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Int) Ptr

func (f *Int) Ptr() *int

Ptr return point value

func (*Int) Scan

func (f *Int) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

func (*Int) SetValue

func (f *Int) SetValue(i int)

SetValue set int value

func (Int) String

func (f Int) String() string

String implements Stringer

func (*Int) UnmarshalJSON

func (f *Int) UnmarshalJSON(data []byte) error

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.

func (Int) Value

func (f Int) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type Int32

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

Int32 int32 wrapper

func NewInt32

func NewInt32(val int32) Int32

func (*Int32) GetValue

func (f *Int32) GetValue() int32

GetValue return int32 value

func (Int32) MarshalJSON

func (f Int32) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Int32) Ptr

func (f *Int32) Ptr() *int32

Ptr return point32 value

func (*Int32) Scan

func (f *Int32) Scan(value interface{}) error

Scan implements the sql.Scanner int32erface.

func (*Int32) SetValue

func (f *Int32) SetValue(i int32)

SetValue set int32 value

func (Int32) String

func (f Int32) String() string

String implements Stringer

func (*Int32) UnmarshalJSON

func (f *Int32) UnmarshalJSON(data []byte) error

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.

func (Int32) Value

func (f Int32) Value() (driver.Value, error)

Value implements the driver.Valuer int32erface.

type Int64

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

Int64 int64 wrapper

func NewInt64

func NewInt64(val int64) Int64

func (*Int64) GetValue

func (f *Int64) GetValue() int64

GetValue return int64 value

func (Int64) MarshalJSON

func (f Int64) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Int64) Ptr

func (f *Int64) Ptr() *int64

Ptr return point64 value

func (*Int64) Scan

func (f *Int64) Scan(value interface{}) error

Scan implements the sql.Scanner int64erface.

func (*Int64) SetValue

func (f *Int64) SetValue(i int64)

SetValue set int64 value

func (Int64) String

func (f Int64) String() string

String implements Stringer

func (*Int64) UnmarshalJSON

func (f *Int64) UnmarshalJSON(data []byte) error

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.

func (Int64) Value

func (f Int64) Value() (driver.Value, error)

Value implements the driver.Valuer int64erface.

type Object

type Object interface {
	IsNull() bool
}

Object base class for any object

type String

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

String string wrapper

func NewString

func NewString(val string) String

func (*String) GetValue

func (s *String) GetValue() string

GetValue return string value

func (*String) HasValue

func (s *String) HasValue() bool

HasValue return true if it is no empty

func (*String) IsNull

func (s *String) IsNull() bool

IsNull implements Object.IsNull

func (String) MarshalJSON

func (s String) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*String) Ptr

func (s *String) Ptr() *string

Ptr return point value

func (*String) Scan

func (s *String) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

func (*String) SetValue

func (s *String) SetValue(v string)

SetValue set string value

func (String) String

func (s String) String() string

String implements Stringer

func (*String) UnmarshalJSON

func (s *String) UnmarshalJSON(data []byte) error

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.

func (String) Value

func (s String) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type StringBuilder

type StringBuilder struct {
	strings.Builder
}

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

type Time struct {
	time.Time
	// contains filtered or unexported fields
}

Time time wrapper

func NewTime

func NewTime(val time.Time) Time

func (*Time) GetValue

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

GetValue return string value

func (*Time) IsNull

func (t *Time) IsNull() bool

IsNull implements Object.IsNull

func (*Time) MarshalBSON

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

func (Time) MarshalJSON

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

MarshalJSON implements json.Marshaler.

func (*Time) Ptr

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

Ptr return point value

func (*Time) Scan

func (t *Time) Scan(value interface{}) (err error)

Scan implements the sql.Scanner interface.

func (*Time) SetContext

func (t *Time) SetContext(ctx context.Context)

SetContext implements Object.SetContext

func (*Time) SetValue

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

SetValue set string value

func (Time) String

func (t Time) String() string

String implements Stringer

func (*Time) UnmarshalBSON

func (t *Time) UnmarshalBSON(data []byte) error

func (*Time) UnmarshalJSON

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

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.

func (Time) Value

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

Value implements the driver.Valuer interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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