-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfold.go
61 lines (44 loc) · 1.2 KB
/
fold.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"fmt"
"strings"
)
func main() {
p := fmt.Println
result := strings.Contains("I love Go Programming!", "love")
p(result)
result = strings.Contains("success", "xy")
p(result)
result = strings.ContainsRune("Golang", 'g')
p(result)
n := strings.Count("cheese", "e")
p(n)
n = strings.Count("Five", "")
p(n)
p(strings.ToLower("Go Python Java"))
p(strings.ToUpper("Go Python Java"))
p(strings.ToUpper("go") == strings.ToUpper("Go"))
p(strings.EqualFold("GO", "go"))
myStr := strings.Replace("192.168.0.1", ".", ":", 2)
p(myStr)
myStr = strings.Replace("192.168.0.1", ".", ":", -1)
p(myStr)
myStr = strings.ReplaceAll("192.168.0.1", ".", ":")
p(myStr)
s := strings.Split("a,b,c", ",")
fmt.Printf("%T\n", s)
fmt.Printf("%#v\n", s)
s = strings.Split("Go for Go!", "")
fmt.Printf("%#v\n", s)
s = []string{"I", "Learn", "Golang"}
myStr = strings.Join(s, " ")
p(myStr)
myStr = "Orange Green \n Blue Yellow"
fields := strings.Fields(myStr)
fmt.Printf("%T\n", fields)
fmt.Printf("%#v\n", fields)
s1 := strings.TrimSpace("\t Goodbye Windows, Welcome Linux! \n")
fmt.Printf("%q\n", s1)
s2 := strings.Trim("...Hello Gophers!!!!?", ".!?")
fmt.Printf("%q\n", s2)
}