xstrings

package module
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2021 License: BSD-3-Clause Imports: 12 Imported by: 0

README

xstrings

Go Reference

provides some extended capabilities according to GoLang's strings

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultIntBase = 10

	DefaultTimeLayout = time.RFC3339

	DefaultFloatFmt  = byte('f')
	DefaultFloatPrec = -1

	DefaultComplexFmt  = byte('f')
	DefaultComplexPrec = -1

	DefaultIndent          = ""
	DefaultMultiLinePrefix = ""
)
View Source
var (
	ErrCanNotGetAddr               = errors.New("can not get address of value")
	ErrNilPointer                  = errors.New("nil pointer error")
	ErrValueMustBeStruct           = errors.New("value must be struct")
	ErrArgumentCountExceeded       = errors.New("argument count exceeded")
	ErrArgumentStructFieldNotFound = errors.New("argument struct field not found")
)

Functions

func AreLettersLower added in v0.9.0

func AreLettersLower(str string) bool

func AreLettersUpper added in v0.9.0

func AreLettersUpper(str string) bool

func IsBeginningLower added in v0.8.0

func IsBeginningLower(str string) bool

func IsBeginningUpper added in v0.8.0

func IsBeginningUpper(str string) bool

func ToLowerBeginning

func ToLowerBeginning(str string) string

func ToUpperBeginning

func ToUpperBeginning(str string) string

func TryUnquote

func TryUnquote(s string) string

Types

type ArgumentParseError added in v0.4.0

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

func (*ArgumentParseError) Error added in v0.4.0

func (e *ArgumentParseError) Error() string

func (*ArgumentParseError) Name added in v0.10.0

func (e *ArgumentParseError) Name() string

func (*ArgumentParseError) Unwrap added in v0.4.0

func (e *ArgumentParseError) Unwrap() error

type ArgumentStruct added in v0.4.0

type ArgumentStruct struct {
	Unmarshaler              *Unmarshaler
	FieldNameBeginsLowerCase bool
	FieldNameFold            bool
	FieldTagKey              string
	FieldOffset              int
	ArgCountMin              int
	ArgCountMax              int
}

func (*ArgumentStruct) Fields added in v0.4.0

func (a *ArgumentStruct) Fields(ifc interface{}) (ArgumentStructFields, error)

func (*ArgumentStruct) FieldsByValue added in v0.4.0

func (a *ArgumentStruct) FieldsByValue(val reflect.Value) (ArgumentStructFields, error)

func (*ArgumentStruct) GetField added in v0.4.1

func (a *ArgumentStruct) GetField(ifc interface{}, name string) (interface{}, string, error)

func (*ArgumentStruct) GetFieldByValue added in v0.4.1

func (a *ArgumentStruct) GetFieldByValue(val reflect.Value, name string) (reflect.Value, string, error)

func (*ArgumentStruct) SetField added in v0.4.0

func (a *ArgumentStruct) SetField(ifc interface{}, name string, values ...string) (interface{}, string, error)

func (*ArgumentStruct) SetFieldByValue added in v0.4.0

func (a *ArgumentStruct) SetFieldByValue(val reflect.Value, name string, values ...string) (reflect.Value, string, error)

func (*ArgumentStruct) Unmarshal added in v0.4.0

func (a *ArgumentStruct) Unmarshal(ifc interface{}, args ...string) error

func (*ArgumentStruct) UnmarshalByValue added in v0.4.0

func (a *ArgumentStruct) UnmarshalByValue(val reflect.Value, args ...string) error

type ArgumentStructField added in v0.4.0

type ArgumentStructField struct {
	Name        string
	Optional    bool
	MinArgCount int
	Variadic    bool
}

type ArgumentStructFields added in v0.4.0

type ArgumentStructFields []ArgumentStructField

func (ArgumentStructFields) String added in v0.4.0

func (a ArgumentStructFields) String() string

type Arguments added in v0.4.0

type Arguments struct {
	Comment rune
}

func (*Arguments) Format added in v0.4.0

func (a *Arguments) Format(args ...string) (string, error)

func (*Arguments) Parse added in v0.4.0

func (a *Arguments) Parse(str string) ([]string, error)

type FormatError

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

FormatError is type of error

func (*FormatError) Error

func (e *FormatError) Error() string

Error is implementation of error

func (*FormatError) Unwrap

func (e *FormatError) Unwrap() error

Unwrap returns wrapped error

type Marshaler

type Marshaler struct {
	IntBase int

	TimeLayout string

	FloatFmt  byte
	FloatPrec int

	ComplexFmt  byte
	ComplexPrec int

	Indent          string
	MultiLinePrefix string

	FuncFormatBool     func(v bool) string
	FuncFormatInt      func(v int64) string
	FuncFormatUint     func(v uint64) string
	FuncFormatFloat    func(v float64) string
	FuncFormatComplex  func(v complex128) string
	FuncFormatTime     func(v time.Time) string
	FuncFormatDuration func(v time.Duration) string
	FuncMarshalData    func(v interface{}) (string, error)
}

func NewMarshaler

func NewMarshaler() *Marshaler

func (*Marshaler) Marshal

func (m *Marshaler) Marshal(ifc interface{}) (string, error)

func (*Marshaler) MarshalByValue

func (m *Marshaler) MarshalByValue(val reflect.Value) (string, error)

type MissingArgumentError added in v0.4.0

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

func (*MissingArgumentError) Error added in v0.4.0

func (e *MissingArgumentError) Error() string

func (*MissingArgumentError) Name added in v0.10.0

func (e *MissingArgumentError) Name() string

func (*MissingArgumentError) Unwrap added in v0.4.0

func (e *MissingArgumentError) Unwrap() error

type ParseError

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

ParseError is type of error

func (*ParseError) Error

func (e *ParseError) Error() string

Error is implementation of error

func (*ParseError) Unwrap

func (e *ParseError) Unwrap() error

Unwrap returns wrapped error

type Unmarshaler

type Unmarshaler struct {
	IntBase int

	TimeLayout string

	FuncParseBool     func(str string) (bool, error)
	FuncParseInt      func(str string) (int64, error)
	FuncParseUint     func(str string) (uint64, error)
	FuncParseFloat    func(str string) (float64, error)
	FuncParseComplex  func(str string) (complex128, error)
	FuncParseTime     func(str string) (time.Time, error)
	FuncParseDuration func(str string) (time.Duration, error)
	FuncUnmarshalData func(str string, ifc interface{}) error
}

func NewUnmarshaler

func NewUnmarshaler() *Unmarshaler

func (*Unmarshaler) Parse

func (u *Unmarshaler) Parse(str string, typ reflect.Type) (interface{}, error)

func (*Unmarshaler) ParseToValue

func (u *Unmarshaler) ParseToValue(str string, typ reflect.Type) (reflect.Value, error)

func (*Unmarshaler) Unmarshal

func (u *Unmarshaler) Unmarshal(str string, ifc interface{}) error

func (*Unmarshaler) UnmarshalByValue

func (u *Unmarshaler) UnmarshalByValue(str string, val reflect.Value) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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