Answers for "append to file in golang"

Go
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)
}
Posted by: Guest on November-27-2020

Browse Popular Code Answers by Language