Documentation
¶
Overview ¶
Package str string handler method.
Index ¶
- Constants
- func Base64Decode(code string) string
- func Base64Encode(origin string) string
- func CamelCase(vStr string) string
- func ClearSpace(s string) string
- func DelQue(que []string, ss ...string) []string
- func FloatSimple(fv string) string
- func GetNotEmpty(strs ...string) string
- func InQuei(s string, que []string) int
- func IsLatinAlpha(alpha string) bool
- func Lcfirst(str string) string
- func LowerStyle(vStr string) string
- func NumberClear(s string) string
- func NumberSplitFormat(n float64, bits ...int) string
- func PadLeft(s string, pad string, le int) string
- func PadRight(s string, pad string, le int) string
- func ParseDuration(dura string) (time.Duration, error)
- func ParseUnicode(s string) string
- func RandStrBase(base string, length int) string
- func Render(tpl string, data any) (string, error)
- func Reverse(s string) string
- func SplitSafe(s, sep string) []string
- func StrQueueToAny(args []string) []any
- func StringAsFloat(s string) float64
- func StringAsI64(s string) int64
- func StringAsInt(s string) int
- func TimeParse(tmStr string) (time.Time, error)
- func TimeParseLayout(tmStr string) (string, error)
- func Ucfirst(str string) string
- type Calc
- type RandString
- type TimeLayoutDetector
- type Url
- Bugs
Examples ¶
Constants ¶
const ( NumberStr = "0123456789" LowerStr = "abcdefghijklmnopqrstuvwxyz" UpperStr = "ABCDEFGHJIKLMNOPQRSTUVWXYZ" )
const CalcAccuracy int8 = 7
Variables ¶
This section is empty.
Functions ¶
func Base64Decode ¶ added in v1.1.0
Base64Decode base64 string decode
func Base64Encode ¶ added in v1.1.0
Base64Encode base64 string encode
func CamelCase ¶ added in v1.1.0
CamelCase camelcase --> snake case covert string to be lower style, like:
`first_name` -> `FirstName`, `get_height_width_rate` -> `GetHeightWidthRate`
snake case --> camelcase
func FloatSimple ¶ added in v1.3.0
FloatSimple Floating-point number string beautification
func GetNotEmpty ¶ added in v1.1.0
GetNotEmpty get not empty by many strings.
func IsLatinAlpha ¶ added in v1.1.0
func LowerStyle ¶ added in v1.1.0
LowerStyle camelcase --> snake case covert string to be lower style, like:
`FirstName` -> `first_name`, `getHeightWidthRate` -> `get_height_width_rate`
func NumberClear ¶ added in v1.4.1
NumberClear number string clear like '_' or ','
func NumberSplitFormat ¶ added in v1.4.1
NumberSplitFormat numeric value segmentation and beautification
func ParseDuration ¶ added in v1.4.2
ParseDuration parse duration by input string data like day/d(default)/天,hour/h/时,minute/m/分,second/s/秒
like: -10d73s, 73h11m1002s, 13分12秒。"-"/"减"/“负” are similar terms
func ParseUnicode ¶ added in v1.4.1
ParseUnicode parse unicode like `\u00001` to real char
func RandStrBase ¶ added in v0.5.1
RandStrBase make rand string by base string.
func StrQueueToAny ¶ added in v1.1.0
StrQueueToAny string slice convert to nany slice
func StringAsFloat ¶ added in v1.3.0
func StringAsI64 ¶ added in v1.4.0
func StringAsInt ¶ added in v1.4.0
func TimeParseLayout ¶ added in v1.3.0
TimeParseLayout Resolve the given time format into (convert to) standard format. The supported formats are as follows(time can be missing): - 2006-01-02 15:04:06 - 2006-01-02 - 2006-1-2 - 2006/01/02 15:04:06 - 2006年01月02日 15:04:06 - 20060102 15:04:06
Types ¶
type Calc ¶ added in v1.3.0
type Calc struct { Accuracy int8 // contains filtered or unexported fields }
Calc String equality operator, which calculates the result of input string equality support: `**,^,*,/,+,-,%`
func NewCalc ¶ added in v1.3.0
NewCalc String Equation Calculation support `f8,exp` to set .Accuracy
Example ¶
cl := NewCalc("3!+2pi") cl.Count() fmt.Printf("%v\n", cl.String()) // 等式中指定精度 cl = NewCalc("f17, 3!+2pi") cl.Count() fmt.Printf("%v\n", cl.String()) cl.Count("3-(2^2-pi)") fmt.Printf("%v\n", cl.String())
Output: 12.2831854 12.28318530717958623 2.14159265358979312
type RandString ¶ added in v0.5.1
type RandString struct { }
RandString rand string creator.
var RandStr RandString
RandStr rand string instance
func (RandString) Letter ¶ added in v0.5.1
func (rs RandString) Letter(length int) string
Letter get random latin alpha.
func (RandString) Lower ¶ added in v0.5.1
func (rs RandString) Lower(length int) string
Lower get lower string
func (RandString) Number ¶ added in v0.5.1
func (rs RandString) Number(length int) string
Number get random number by length
func (RandString) SafeStr ¶ added in v0.5.1
func (rs RandString) SafeStr(length int) string
SafeStr get safe string not contain special symbol
func (RandString) String ¶ added in v0.5.1
func (rs RandString) String(length int) string
随机字符串 包含: +_.空格/
func (RandString) Upper ¶ added in v0.5.1
func (rs RandString) Upper(length int) string
Upper get upper string
type TimeLayoutDetector ¶ added in v1.3.0
type TimeLayoutDetector struct {
// contains filtered or unexported fields
}
func NewTimeLotDtr ¶ added in v1.3.0
func NewTimeLotDtr(tmStr string) *TimeLayoutDetector
func (*TimeLayoutDetector) Layout ¶ added in v1.3.0
func (c *TimeLayoutDetector) Layout() string
func (*TimeLayoutDetector) Parse ¶ added in v1.3.0
func (c *TimeLayoutDetector) Parse() (string, error)
type Url ¶ added in v0.5.0
type Url struct { }
Url only any the url methods of namespace
func (Url) AbsHref ¶ added in v0.5.0
AbsHref Get the absolute address of the path: path address path, URL is the top-level path, which can be empty BUG(AbsHref): Url.AbsHref 中解析 "vpath" `test/p1/p2` 与 `./test/p1/p2` 的一致性问题
Example ¶
var u Url // "joshua/conero" 与 "./joshua/conero" 效果相同 fmt.Println(u.AbsHref("joshua/conero", "https://www.about.me/url/example/test")) fmt.Println(u.AbsHref("/joshua/conero", "https://www.about.me/url/example/test")) // "//" 等符合可被清除 fmt.Println(u.AbsHref("//joshua/conero", "https://www.about.me/url/example/test")) fmt.Println(u.AbsHref("../../joshua/conero", "https://www.about.me/url/example/test"))
Output: https://www.about.me/url/example/test/joshua/conero https://www.about.me/joshua/conero https://www.about.me/joshua/conero https://www.about.me/joshua/conero
Notes ¶
Bugs ¶
Url.AbsHref 中解析 "vpath" `test/p1/p2` 与 `./test/p1/p2` 的一致性问题