Documentation ¶
Overview ¶
Package str string handler method.
Index ¶
- Constants
- func Base64Decode(code string) string
- func Base64Encode(origin string) string
- func GetNotEmpty(strs ...string) string
- func InQuei(s string, que []string) int
- func JsonTagName(name string) string
- func PadLeft(s string, pad string, le int) string
- func PadRight(s string, pad string, le int) string
- func QueueMaxLen(vList []string) int
- func RandStrBase(base string, length int) string
- func Render(tpl string, data any) (string, error)
- func SplitSafe(s, sep string) []string
- func TimeParse(tmStr string) (time.Time, error)
- func TimeParseLayout(tmStr string) (string, error)
- type RandString
- type Str
- type TimeLayoutDetector
- type Url
- Bugs
Examples ¶
Constants ¶
const ( NumberStr = "0123456789" LowerStr = "abcdefghijklmnopqrstuvwxyz" UpperStr = "ABCDEFGHJIKLMNOPQRSTUVWXYZ" )
Variables ¶
This section is empty.
Functions ¶
func GetNotEmpty ¶
GetNotEmpty get not empty by many strings.
func InQuei ¶
InQuei checkout substring exist in array that case-insensitive
func JsonTagName ¶
JsonTagName get json name omit option like `json:"name,omitempty"` and so on.
func PadLeft ¶
PadLeft string pad substring from left.
func PadRight ¶
PadRight string pad substring from right.
func QueueMaxLen ¶
QueueMaxLen gets the maximum length of a value in an array
func RandStrBase ¶
RandStrBase make rand string by base string.
func Render ¶
Render 根据 go template 模板编译后返回数据 支持 template 模板语法
func TimeParseLayout ¶
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) 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
type Str ¶
type Str string
func (Str) CamelCase ¶
CamelCase camelcase --> snake case covert string to be lower style, like:
`first_name` -> `FirstName`, `get_height_width_rate` -> `GetHeightWidthRate`
snake case --> camelcase
func (Str) Lcfirst ¶
Lcfirst converts the first character of each word in a string to lowercase.
func (Str) LowerStyle ¶
LowerStyle camelcase --> snake case covert string to be lower style, like:
`FirstName` -> `first_name`, `getHeightWidthRate` -> `get_height_width_rate`
func (Str) ParseUnicode ¶
ParseUnicode parse unicode like `\u00001` to real char
func (Str) Ucfirst ¶
Ucfirst converts the first character of each word in a string to uppercase.
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 ¶
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` 的一致性问题