Golang
Loop Over List
// for example:
x := []int{1, 2, 3}
for _, y := range x {
// ...
}
New Map
x := map[string]int{}
y := make(map[string]int, 4)
z := map[string]int{
"one": 1,
"two": 2,
}
String to Stream
s := "foo"
buf := bytes.NewBuffer([]byte(s))
Split a string
s := "foo bar"
parts := strings.Split(s, " ")
Read File to String
func Ex() (string, error) {
bts, e := ioutil.ReadFile("/path/to/file.txt")
if e != nil {
return "", e
}
return string(bts), nil
}
Unmarshal JSON
Parse URL
Reverse a String
Read a File