Skip to content

Commit

Permalink
added csv.NewFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
ungerik committed Sep 11, 2023
1 parent 891bdad commit 644281f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions csv/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ type Format struct {
Newline string `json:"newline"`
}

// NewFormat returns a Format with the passed separator,
// UTF-8 encoding, and "\r\n" newlines.
func NewFormat(separator string) *Format {
return &Format{
Encoding: "UTF-8",
Separator: separator,
Newline: "\r\n",
}
}

// Validate returns an error in case of an invalid Format.
// Can be called on nil receiver.
func (f *Format) Validate() error {
Expand Down

0 comments on commit 644281f

Please sign in to comment.