Go语言写入文件详解
package main
import (
"log"
"os"
)
func main() {
file, err := os.OpenFile("test.txt", os.O_WRONLY|os.O_APPEND, 0666)
if err != nil {
log.Fatal(err)
}
defer file.Close()
_, err = file.WriteString("Append Hello World")
if err != nil {
log.Fatal(err)
}
}