小怪兽爱吃肉
sqltocsv.WriteFile(...)如果文件不存在,应该为您创建该文件。在底层,它只使用os.Create(...)标准库中的内容。github.com/joho/sqltocsv/sqltocsv.go:// WriteFile writes the CSV to the filename specified, return an error if problemfunc (c Converter) WriteFile(csvFileName string) error { f, err := os.Create(csvFileName) if err != nil { return err } err = c.Write(f) if err != nil { f.Close() // close, but only return/handle the write error return err } return f.Close()}文档os.Create(...):// Create creates the named file with mode 0666 (before umask), truncating// it if it already exists. If successful, methods on the returned// File can be used for I/O; the associated file descriptor has mode// O_RDWR.// If there is an error, it will be of type *PathError.func Create(name string) (*File, error) { return OpenFile(name, O_RDWR|O_CREATE|O_TRUNC, 0666)}