package main
import (
"encoding/csv"
"fmt"
"os"
)
func main() {
file, err := os.OpenFile("111.csv", os.O_CREATE|os.O_RDWR, 0644)
if err != nil {
fmt.Println("open file is failed, err: ", err)
}
defer file.Close()
// 写入UTF-8 BOM,防止中文乱码
file.WriteString("xEFxBBxBF")
w := csv.NewWriter(file)
w.Write([]string{"开发者名称", "开发者邮箱", "应用名称"})
// 写文件需要flush,不然缓存满了,后面的就写不进去了,只会写一部分
w.Flush()
}