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 ToFloat32(str string) (float32, error)
- func ToFloat64(str string) (float64, error)
- func ToInt(str string) (int, error)
- func ToInt8(str string) (int8, error)
- func ToInt16(str string) (int16, error)
- func ToInt32(str string) (int32, error)
- func ToInt64(str string) (int64, error)
- func ToUint(str string) (uint, error)
- func ToUint8(str string) (uint8, error)
- func ToUint16(str string) (uint16, error)
- func ToUint32(str string) (uint32, error)
- func ToUint64(str string) (uint64, error)
- 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 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.