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 GetNotEmpty(strs ...string) string
- func InQue(s string, que []string) int
- func InQuei(s string, que []string) int
- func IsLatinAlpha(alpha string) bool
- func Lcfirst(str string) string
- func LowerStyle(vStr string) string
- func PadLeft(s string, pad string, le int) string
- func PadRight(s string, pad string, le int) string
- func RandStrBase(base string, length int) string
- func Render(tpl string, data interface{}) (string, error)
- func Reverse(s string) string
- func SplitSafe(s, sep string) []string
- type RandString
- type Url
- Bugs
Examples ¶
Constants ¶
const ( NumberStr = "0123456789" LowerStr = "abcdefghijklmnopqrstuvwxyz" UpperStr = "ABCDEFGHJIKLMNOPQRSTUVWXYZ" )
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 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 RandStrBase ¶ added in v0.5.1
RandStrBase make rand string by base string.
Types ¶
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 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` 的一致性问题