From 2f2b4b60719d8dcff3bac2a48f4bfd3499873423 Mon Sep 17 00:00:00 2001 From: chenall Date: Thu, 23 May 2024 16:20:25 +0800 Subject: [PATCH] New CsvOption - UseCRLF (#30) True to use \r\n as the line terminator --- csvtag.go | 1 + dump.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/csvtag.go b/csvtag.go index 20f3e8e..5f22689 100644 --- a/csvtag.go +++ b/csvtag.go @@ -3,6 +3,7 @@ package csvtag // CsvOptions - options when loading or dumping csv. type CsvOptions struct { Separator rune + UseCRLF bool // True to use \r\n as the line terminator Header []string TagKey string } diff --git a/dump.go b/dump.go index 8fc0020..7c3d203 100644 --- a/dump.go +++ b/dump.go @@ -51,6 +51,8 @@ func DumpToWriter(slice interface{}, writer io.Writer, options ...CsvOptions) er csvWriter.Comma = option.Separator } + csvWriter.UseCRLF = option.UseCRLF + err := csvWriter.Write(option.Header) if err != nil { return err