Documentation
¶
Index ¶
- Constants
- Variables
- func Debug(messagePattern string, args ...any)
- func Debugf(messagePattern string, args ...any)
- func Errorf(messagePattern string, args ...any) error
- func FormatString(messagePattern string, args ...any) string
- func IndexOf(str, substr string, index int) int
- func Print(messagePattern string, args ...any)
- func Printf(messagePattern string, args ...any)
- func Println(messagePattern string, args ...any)
- func Sprintf(messagePattern string, args ...any) string
- func ThrowableCandidate(args []any) error
- func ToBool(str string) (bool, error)
- func ToBoolNoThrow(str string) (bool, bool)
- func ToDateTime(str string) (*time.Time, bool)
- func ToDateTimeByFormat(str string, format string) (*time.Time, bool)
- func ToDateTimeByFormatWithLocation(str string, format string, offset int) (*time.Time, bool)
- func ToFloat32(str string) (float32, error)
- func ToFloat32NoThrow(str string) (float32, bool)
- func ToFloat64(str string) (float64, error)
- func ToFloat64NoThrow(str string) (float64, bool)
- func ToInt(str string) (int, error)
- func ToInt8(str string) (int8, error)
- func ToInt8NoThrow(str string) (int8, bool)
- func ToInt16(str string) (int16, error)
- func ToInt16NoThrow(str string) (int16, bool)
- func ToInt32(str string) (int32, error)
- func ToInt32NoThrow(str string) (int32, bool)
- func ToInt64(str string) (int64, error)
- func ToInt64NoThrow(str string) (int64, bool)
- func ToIntNoThrow(str string) (int, bool)
- func ToTimestamp(str string) (uint64, bool)
- func ToTimestampForMilli(str string) (uint64, bool)
- func ToUint(str string) (uint, error)
- func ToUint8(str string) (uint8, error)
- func ToUint8NoThrow(str string) (uint8, bool)
- func ToUint16(str string) (uint16, error)
- func ToUint16NoThrow(str string) (uint16, bool)
- func ToUint32(str string) (uint32, error)
- func ToUint32NoThrow(str string) (uint32, bool)
- func ToUint64(str string) (uint64, error)
- func ToUint64NoThrow(str string) (uint64, bool)
- func ToUintNoThrow(str string) (uint, bool)
- func TrimSpace(str string) string
- func TrimmedCopy(args []any) ([]any, error)
- type FormattingTuple
- func ArrayFormat(messagePattern string, argArray []any) *FormattingTuple
- func ArrayFormatWithError(messagePattern string, argArray []any, throwable error) *FormattingTuple
- func Format(messagePattern string, arg any) *FormattingTuple
- func FormatArgs(messagePattern string, arg1, arg2 any) *FormattingTuple
- func NewFormattingTuple(message string, args []any, throwable error) *FormattingTuple
- func SliceFormat(messagePattern string, args ...any) *FormattingTuple
- type KParameter
- type StringParams
- func (that *StringParams) Build() string
- func (that *StringParams) Get() *klists.KList[string]
- func (that *StringParams) GetFuncName() *klists.KList[string]
- func (that *StringParams) GetVarName() *klists.KList[string]
- func (that *StringParams) Set(param string, value string) *StringParams
- func (that *StringParams) SetFunc(param string, value string) *StringParams
- func (that *StringParams) SetVar(param string, value string) *StringParams
- type TYPE
Constants ¶
View Source
const ( DELIM_START = '{' DELIM_STOP = '}' DELIM_STR = "{}" ESCAPE_CHAR = '\\' )
View Source
const ( DATETIME_FORMATTER = "2006-01-02 15:04:05" DATETIME_FORMATTER_Mill = "2006-01-02 15:04:05.000" DATETIME_TIMEZONE_FORMATTER = "2006-01-02 15:04:05 -0700" )
Variables ¶
View Source
var (
ErrSampleString = fmt.Errorf("%s", "sample string")
)
Functions ¶
func FormatString ¶
func ThrowableCandidate ¶
func ToBoolNoThrow ¶ added in v0.4.5
func ToDateTimeByFormat ¶ added in v0.4.5
func ToDateTimeByFormatWithLocation ¶ added in v0.4.5
ToDateTimeByFormatWithLocation 根据指定的格式和时区偏移量将字符串转换为时间对象
该函数会先去除字符串两端的空白字符,然后使用指定的时区偏移量来解析时间字符串。 如果解析成功,返回时间对象和true;如果解析失败,返回nil和false。
@param str 要解析的时间字符串 @param time.ParseInLocation函数使用的格式字符串 @param offset 时区偏移量,单位为秒(东八区为+28800) @return 解析成功返回*time.Time对象,失败返回nil @return 解析成功返回true,失败返回false
func ToFloat32NoThrow ¶ added in v0.4.5
func ToFloat64NoThrow ¶ added in v0.4.5
func ToInt8NoThrow ¶ added in v0.4.5
func ToInt16NoThrow ¶ added in v0.4.5
func ToInt32NoThrow ¶ added in v0.4.5
func ToInt64NoThrow ¶ added in v0.4.5
func ToIntNoThrow ¶ added in v0.4.5
func ToTimestamp ¶ added in v0.4.5
func ToTimestampForMilli ¶ added in v0.4.5
func ToUint8NoThrow ¶ added in v0.4.5
func ToUint16NoThrow ¶ added in v0.4.5
func ToUint32NoThrow ¶ added in v0.4.5
func ToUint64NoThrow ¶ added in v0.4.5
func ToUintNoThrow ¶ added in v0.4.5
func TrimmedCopy ¶
@bref Helper method to get all but the last element of an array
- @param argArray The arguments from which we want to remove the last element
- @return a copy of the array without the last element
Types ¶
type FormattingTuple ¶
type FormattingTuple struct {
// contains filtered or unexported fields
}
func ArrayFormat ¶
func ArrayFormat(messagePattern string, argArray []any) *FormattingTuple
func ArrayFormatWithError ¶
func ArrayFormatWithError(messagePattern string, argArray []any, throwable error) *FormattingTuple
func Format ¶
func Format(messagePattern string, arg any) *FormattingTuple
@bref Performs single argument substitution for the 'messagePattern' passed as parameter.
- For example,
- -- MessageFormatter.format("Hi {}.", "there");
- -- will return the string "Hi there.".
- @param messagePattern The message pattern which will be parsed and formatted
- @param arg The argument to be substituted in place of the formatting anchor
- @return The formatted message
func FormatArgs ¶
func FormatArgs(messagePattern string, arg1, arg2 any) *FormattingTuple
Performs a two argument substitution for the 'messagePattern' passed as parameter.
- For example,
- -- MessageFormatter.format("Hi {}. My name is {}.", "Alice", "Bob");
- -- will return the string "Hi Alice. My name is Bob.".
- @param messagePattern The message pattern which will be parsed and formatted
- @param arg1 The argument to be substituted in place of the first formatting anchor
- @param arg2 The argument to be substituted in place of the second formatting anchor
- @return The formatted message
func NewFormattingTuple ¶
func NewFormattingTuple(message string, args []any, throwable error) *FormattingTuple
func SliceFormat ¶
func SliceFormat(messagePattern string, args ...any) *FormattingTuple
func (*FormattingTuple) Args ¶
func (its *FormattingTuple) Args() []any
func (*FormattingTuple) Message ¶
func (its *FormattingTuple) Message() string
func (*FormattingTuple) Throwable ¶
func (its *FormattingTuple) Throwable() error
type KParameter ¶
type KParameter string
func (KParameter) Type ¶
func (that KParameter) Type() TYPE
func (KParameter) TypeString ¶
func (that KParameter) TypeString() string
type StringParams ¶
type StringParams struct {
// contains filtered or unexported fields
}
字符串参数解析与处理
- 例如: "hello word ${param1}! i'm $(param3), fuck off ${param2}..."
- - ${param1} ${} 代表变量
- - $(param3) $() 代表方法
func (*StringParams) GetFuncName ¶
func (that *StringParams) GetFuncName() *klists.KList[string]
func (*StringParams) GetVarName ¶
func (that *StringParams) GetVarName() *klists.KList[string]
func (*StringParams) Set ¶
func (that *StringParams) Set(param string, value string) *StringParams
指定一个变量的值, 如变量不存在, 不做任何操作
func (*StringParams) SetFunc ¶
func (that *StringParams) SetFunc(param string, value string) *StringParams
指定一个方法的值, 如方法不存在, 不做任何操作
func (*StringParams) SetVar ¶
func (that *StringParams) SetVar(param string, value string) *StringParams
指定一个变量的值, 如变量不存在, 不做任何操作
Click to show internal directories.
Click to hide internal directories.