This is a creation in
Article, where the information may have evolved or changed.
Only the use of partial function methods is listed:
Too much.......
Package Mainimport ("FMT" "Strings"Func Main () {count computes the non-overlapping number of Sep in S, func Count (S, substrstring)int{s:="Hello, super brother."Count l occurrences N:= Strings. Count (S,"L") fmt. PRINTLN (n)//2If substr is empty, returns the number of characters in S +1N=strings. Count (S,"") fmt. PRINTLN (n) Contains determines whether the string s contains substrings substr func Contains (S, substrstring)BOOL{substr writes nothing, returns True if present returns True, otherwise false s:="Hello, super brother!!"B:= Strings. Contains (s),"!") fmt. Println (b)//trueb = Strings. Contains (s),"@")//falseFMT. Println (b) B=strings. Contains (s),"") fmt. Println (b) Containsany determines whether the string s contains any of the characters in chars if char is null, returns false Func Containsany (s, charsstring)BOOL{s:="Hello, super brother."B:= Strings. Containsany (s),"ABC") fmt. Println (b)//falseB=strings. Containsany (s),"def")//trueFMT. Println (b) B=strings. Containsany (s),"")//falseFMT. Println (b) Containsrune determines whether the string s contains a character R rune cannot be null, exists true, otherwise false func Containsrune (sstring, R Rune)BOOL{s:="Hello, super brother!"B:= Strings. Containsrune (s),'\ n') fmt. Println (b)//falseb = Strings. Containsrune (s),'Super') fmt. Println (b)//trueb = Strings. Containsrune (s),'o') fmt. Println (b)//trueIndexany Returns the position (index) of the first occurrence of any character in the string chars in the string s .-1, chars is also returned as null-1func strings. Indexany () s:="Hello, super brother! Hello!"B:= Strings. Indexany (s),"ABC") fmt. Println (b)//-1b = Strings. Indexany (s),"") fmt. Println (b)//-1b = Strings. Indexany (s),"Super") fmt. Println (b) Lastindexany returns the last occurrence of any one of the string s in the string chars.-1, chars is also returned as null-1func Lastindexany (S, charsstring)int{s:="Hello, the world! Hello! "B:=strings. Lastindexany (s),"ABC") fmt. Println (b)//-1B=strings. Lastindexany (s),"World") fmt. Println (b)//6 Last occurrence of index positionB=strings. Lastindexany (s),"") fmt. Println (b)//-1}
Comparison of the whole is Golang Chinese network: https://studygolang.com/articles/5769