GO語言"encoding/csv"包中"Writer.WriteAll"類型的用法及代碼示例。
用法:
func(w *Writer) WriteAll(records [][]string) error
WriteAll 使用 Write 將多個 CSV 記錄寫入 w,然後調用 Flush,從 Flush 返回任何錯誤。
例子:
package main
import (
"encoding/csv"
"log"
"os"
)
func main() {
records := [][]string{
{"first_name", "last_name", "username"},
{"Rob", "Pike", "rob"},
{"Ken", "Thompson", "ken"},
{"Robert", "Griesemer", "gri"},
}
w := csv.NewWriter(os.Stdout)
w.WriteAll(records) // calls Flush internally
if err := w.Error(); err != nil {
log.Fatalln("error writing csv:", err)
}
}
輸出:
first_name,last_name,username Rob,Pike,rob Ken,Thompson,ken Robert,Griesemer,gri
相關用法
- GO Writer.Init用法及代碼示例
- GO Writer.RegisterCompressor用法及代碼示例
- GO Writer.AvailableBuffer用法及代碼示例
- GO Writer用法及代碼示例
- GO WriteFile用法及代碼示例
- GO WriteString用法及代碼示例
- GO Write用法及代碼示例
- GO WithDeadline用法及代碼示例
- GO WordEncoder.Encode用法及代碼示例
- GO WaitGroup用法及代碼示例
- GO WordDecoder.Decode用法及代碼示例
- GO WordDecoder.DecodeHeader用法及代碼示例
- GO WithValue用法及代碼示例
- GO WalkDir用法及代碼示例
- GO WithTimeout用法及代碼示例
- GO WithCancel用法及代碼示例
- GO Walk用法及代碼示例
- GO PutUvarint用法及代碼示例
- GO Scanner.Scan用法及代碼示例
- GO LeadingZeros32用法及代碼示例
注:本文由純淨天空篩選整理自golang.google.cn大神的英文原創作品 Writer.WriteAll。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。