str

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package str string handler method.

Index

Examples

Constants

View Source
const (
	NumberStr = "0123456789"
	LowerStr  = "abcdefghijklmnopqrstuvwxyz"
	UpperStr  = "ABCDEFGHJIKLMNOPQRSTUVWXYZ"
)

Variables

This section is empty.

Functions

func Base64Decode added in v1.1.0

func Base64Decode(code string) string

Base64Decode base64 string decode

func Base64Encode added in v1.1.0

func Base64Encode(origin string) string

Base64Encode base64 string encode

func CamelCase added in v1.1.0

func CamelCase(vStr string) string

CamelCase camelcase --> snake case covert string to be lower style, like:

`first_name` 			-> `FirstName`,
`get_height_width_rate` 	-> `GetHeightWidthRate`

snake case --> camelcase

func ClearSpace added in v0.3.1

func ClearSpace(s string) string

ClearSpace clear string space

func DelQue

func DelQue(que []string, ss ...string) []string

DelQue del queue from array

func FloatSimple added in v1.3.0

func FloatSimple(fv string) string

FloatSimple Floating-point number string beautification

func GetNotEmpty added in v1.1.0

func GetNotEmpty(strs ...string) string

GetNotEmpty get not empty by many strings.

func InQue deprecated

func InQue(s string, que []string) int

InQue checkout substring exist in array

Deprecated: As of Go 1.16, this function simply calls util.ListIndex.

func InQuei

func InQuei(s string, que []string) int

InQuei checkout substring exist in array that case insensitive

func IsLatinAlpha added in v1.1.0

func IsLatinAlpha(alpha string) bool

func Lcfirst

func Lcfirst(str string) string

Lcfirst converts the first character of each word in a string to lowercase.

func LowerStyle added in v1.1.0

func LowerStyle(vStr string) string

LowerStyle camelcase --> snake case covert string to be lower style, like:

`FirstName` 			-> `first_name`,
`getHeightWidthRate` 	-> `get_height_width_rate`

func PadLeft added in v0.5.0

func PadLeft(s string, pad string, le int) string

PadLeft string pad substring from left.

func PadRight added in v0.5.0

func PadRight(s string, pad string, le int) string

PadRight string pad substring from right.

func RandStrBase added in v0.5.1

func RandStrBase(base string, length int) string

RandStrBase make rand string by base string.

func Render added in v0.3.1

func Render(tpl string, data any) (string, error)

Render 根据 go template 模板编译后返回数据 支持 template 模板语法

func Reverse added in v0.4.1

func Reverse(s string) string

Reverse string reverse

func SplitSafe added in v0.3.1

func SplitSafe(s, sep string) []string

SplitSafe split safe string

func StrQueueToAny added in v1.1.0

func StrQueueToAny(args []string) []any

StrQueueToAny string slice convert to nany slice

func StringAsFloat added in v1.3.0

func StringAsFloat(s string) float64

func TimeParse added in v1.3.0

func TimeParse(tmStr string) (time.Time, error)

func TimeParseLayout added in v1.3.0

func TimeParseLayout(tmStr string) (string, error)

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

func NewCalc(equality string) *Calc

func (*Calc) Count added in v1.3.0

func (c *Calc) Count(args ...string) float64

func (*Calc) Exp added in v1.3.0

func (c *Calc) Exp(eq string) string

Exp support functional expression eg. sprt,log Notice: Attempt to expose it to external interfaces

func (*Calc) String added in v1.3.0

func (c *Calc) String() string

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

func (u Url) AbsHref(vpath, vurl string) string

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` 的一致性问题

Jump to

Keyboard shortcuts

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