str

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

字符串处理工具包

Index

Examples

Constants

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

Variables

This section is empty.

Functions

func Base64_decode added in v0.5.1

func Base64_decode(code string) string

base64 解码

func Base64_encode added in v0.5.1

func Base64_encode(origin string) string

base64 编码

func ClearSpace added in v0.3.1

func ClearSpace(s string) string

清除空格

func DelQue

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

删除队列

func InQue

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

字符串对是否存在 不存在返回 -1

func InQuei

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

不区分大小写

func Lcfirst

func Lcfirst(str string) string

首字母小写

func PadLeft added in v0.5.0

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

向左填充

func PadRight added in v0.5.0

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

向右填充

func RandStrBase added in v0.5.1

func RandStrBase(base string, length int) string

数据字符串生成基函数

func Render added in v0.3.1

func Render(tpl string, data interface{}) (string, error)

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

func Reverse added in v0.4.1

func Reverse(s string) string

字符串反转

func SplitSafe added in v0.3.1

func SplitSafe(s, sep string) []string

安全字符串分割

func Ucfirst

func Ucfirst(str string) string

首字母大写

Types

type RandString added in v0.5.1

type RandString struct {
}

随机字符串生成器

var RandStr RandString

随机字符串

func (RandString) Letter added in v0.5.1

func (rs RandString) Letter(length int) string

随机字母

func (RandString) Lower added in v0.5.1

func (rs RandString) Lower(length int) string

随机小写字母

func (RandString) Number added in v0.5.1

func (rs RandString) Number(length int) string

随机数字

func (RandString) SafeStr added in v0.5.1

func (rs RandString) SafeStr(length int) string

随机安全字符,没有特殊符号

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

随机大写字母

type Url added in v0.5.0

type Url struct {
}

URL 相关处理类

func (Url) AbsHref added in v0.5.0

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

获取路径的绝对地址: path 地址路径, url 为顶级路径可为空

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

type WriterToContent added in v0.3.1

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

写入器导出为内容

func (*WriterToContent) Content added in v0.3.1

func (wr *WriterToContent) Content() string

获取值

func (*WriterToContent) Write added in v0.3.1

func (wr *WriterToContent) Write(p []byte) (n int, err error)

实现写入器语法

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