From ce06bdb16a64dd39a8ebbb2e5a53b33520b00bb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Sun, 23 Dec 2018 21:08:12 +0100 Subject: Rename CSV option from comma to delimiter See #5555 --- parser/metadecoders/decoder.go | 8 ++++---- parser/metadecoders/format.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'parser') diff --git a/parser/metadecoders/decoder.go b/parser/metadecoders/decoder.go index 0ca8575fe..2f3c27d45 100644 --- a/parser/metadecoders/decoder.go +++ b/parser/metadecoders/decoder.go @@ -31,8 +31,8 @@ import ( // Decoder provides some configuration options for the decoders. type Decoder struct { - // Comma is the field delimiter used in the CSV decoder. It defaults to ','. - Comma rune + // Delimiter is the field delimiter used in the CSV decoder. It defaults to ','. + Delimiter rune // Comment, if not 0, is the comment character ued in the CSV decoder. Lines beginning with the // Comment character without preceding whitespace are ignored. @@ -41,7 +41,7 @@ type Decoder struct { // Default is a Decoder in its default configuration. var Default = Decoder{ - Comma: ',', + Delimiter: ',', } // UnmarshalToMap will unmarshall data in format f into a new map. This is @@ -156,7 +156,7 @@ func (d Decoder) unmarshal(data []byte, f Format, v interface{}) error { func (d Decoder) unmarshalCSV(data []byte, v interface{}) error { r := csv.NewReader(bytes.NewReader(data)) - r.Comma = d.Comma + r.Comma = d.Delimiter r.Comment = d.Comment records, err := r.ReadAll() diff --git a/parser/metadecoders/format.go b/parser/metadecoders/format.go index 719fbf100..4f81528c3 100644 --- a/parser/metadecoders/format.go +++ b/parser/metadecoders/format.go @@ -92,7 +92,7 @@ func FormatFromFrontMatterType(typ pageparser.ItemType) Format { // in the given string. // It return an empty string if no format could be detected. func (d Decoder) FormatFromContentString(data string) Format { - csvIdx := strings.IndexRune(data, d.Comma) + csvIdx := strings.IndexRune(data, d.Delimiter) jsonIdx := strings.Index(data, "{") yamlIdx := strings.Index(data, ":") tomlIdx := strings.Index(data, "=") -- cgit v1.2.3