append in golang code example
Example 1: append to file in golang
f, err := os.OpenFile(filename, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
if err != nil {
panic(err)
}
defer f.Close()
if _, err = f.WriteString(text); err != nil {
panic(err)
}
Example 2: go add to slice
var s []int
s = append(s, 0)