str

package
v2.0.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package str string handler method.

Index

Constants

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

Variables

This section is empty.

Functions

func Base64Decode

func Base64Decode(code string) string

Base64Decode base64 string decode

func Base64Encode

func Base64Encode(origin string) string

Base64Encode base64 string encode

func GetNotEmpty

func GetNotEmpty(strs ...string) string

GetNotEmpty get not empty by many strings.

func InQuei

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

InQuei checkout substring exist in array that case insensitive

func PadLeft

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

PadLeft string pad substring from left.

func PadRight

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

PadRight string pad substring from right.

func QueueMaxLen

func QueueMaxLen(vList []string) int

QueueMaxLen gets the maximum length of a value in an array

func RandStrBase

func RandStrBase(base string, length int) string

RandStrBase make rand string by base string.

func Render

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

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

func SplitSafe

func SplitSafe(s, sep string) []string

SplitSafe split safe string

func TimeParse

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

func TimeParseLayout

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 RandString

type RandString struct {
}

RandString rand string creator.

var RandStr RandString

RandStr rand string instance

func (RandString) Letter

func (rs RandString) Letter(length int) string

Letter get random latin alpha.

func (RandString) Lower

func (rs RandString) Lower(length int) string

Lower get lower string

func (RandString) Number

func (rs RandString) Number(length int) string

Number get random number by length

func (RandString) SafeStr

func (rs RandString) SafeStr(length int) string

SafeStr get safe string not contain special symbol

func (RandString) String

func (rs RandString) String(length int) string

随机字符串 包含: +_.空格/

func (RandString) Upper

func (rs RandString) Upper(length int) string

Upper get upper string

type Str

type Str string

func (Str) CamelCase

func (s Str) CamelCase() string

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

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

snake case --> camelcase

func (Str) ClearSpace

func (s Str) ClearSpace() string

ClearSpace clear string space

func (Str) IsLatinAlpha

func (s Str) IsLatinAlpha() bool

func (Str) Lcfirst

func (s Str) Lcfirst() string

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

func (Str) LowerStyle

func (s Str) LowerStyle() string

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

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

func (Str) ParseUnicode

func (s Str) ParseUnicode() string

ParseUnicode parse unicode like `\u00001` to real char

func (Str) Reverse

func (s Str) Reverse() string

Reverse string reverse

func (Str) Ucfirst

func (s Str) Ucfirst() string

Ucfirst converts the first character of each word in a string to uppercase.

func (Str) Unescape

func (s Str) Unescape() string

Unescape Parses transcoding symbols in strings, support \s|\n

type TimeLayoutDetector

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

func NewTimeLotDtr

func NewTimeLotDtr(tmStr string) *TimeLayoutDetector

func (*TimeLayoutDetector) Layout

func (c *TimeLayoutDetector) Layout() string

func (*TimeLayoutDetector) Parse

func (c *TimeLayoutDetector) Parse() (string, error)

type Url

type Url struct {
}

Url only any the url methods of namespace

func (Url) AbsHref

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

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