system handlers common golang

1. Statistical string length, in bytes len (str)

2. String traversal problem while processing a Chinese r: = [] rune (str)

3. String to Integer: n, err: = strconv.Atoi ( "1234")

4. Integer String str = strconv.Itoa (12345)

The string rotation [] byte: var bytes = [] byte ( "hello go")

6. [] byte string rotation: str = string ([] byte {97, 98, 99})

7.10, 8, 16 turn hex hex: str = strconv.FormatInt (123, decimal digits)

8. Find a substring in a string enacted in: strings.Contains ( "seafood", "foo") // true

There are several statistical 9. A string specified substring: strings.Count ( "ceheese", "e") // 4

10 is not case-sensitive string comparison (== is case sensitive): strings.EqualFold ( "abc", "Abc") // true

11. Return the string index value for the first occurrence, if none -1: strings.Index ( "go golang", "go") // 0

12. Return the last substring in the string that appears in the index, if not returned -1: strings.LastIndex ( "go golang") // 3

13. The specified substring replace another substring: string.Replace ( "go go hello", "go", "golang", n) // n represents the number of replacement, if n = -1 Replace

14. a character specified for the identifiers for a string split into an array of strings: strings.Split ( "Hello, Word, OK", "," )

15. The letter of the string case conversion: strings.ToLower ( "Go") //strings.ToUpper("Go ")

16. The string of right and left spaces removed: strings.TrimSpace ( "tn a long")

17. The right and left string specified string is removed: strings.Trim (, "hello!!" "!")

18. The left side of the specified string of characters removed: strings.TrimLeft (, "hello!!" "!")

19. The right of the specified string of characters removed: strings.TrimRight (, "hello!!" "!")

20. determines whether the beginning of the string specified string: strings.HasPrefix ( "FTP: 0.0.0.0", "FTP" )

21. determines whether the end of the string specified string: strings.HasSuffix ( "001.jpg", "jpg")

Guess you like

Origin www.cnblogs.com/xianqingsong/p/11756240.html