-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoption.go
40 lines (34 loc) · 958 Bytes
/
option.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package csv
import (
"github.com/nicksnyder/go-i18n/v2/i18n"
)
// Option is a function that sets a configuration option for CSV struct.
type Option func(c *CSV) error
// WithTabDelimiter is an Option that sets the delimiter to a tab character.
func WithTabDelimiter() Option {
return func(c *CSV) error {
c.reader.Comma = '\t'
return nil
}
}
// WithHeaderless is an Option that sets the headerless flag to true.
func WithHeaderless() Option {
return func(c *CSV) error {
c.headerless = true
return nil
}
}
// WithJapaneseLanguage is an Option that sets the i18n bundle to Japanese.
func WithJapaneseLanguage() Option {
return func(c *CSV) error {
c.i18nLocalizer = i18n.NewLocalizer(c.i18nBundle, "ja")
return nil
}
}
// WithRussianLanguage is an Option that sets the i18n bundle to Russian.
func WithRussianLanguage() Option {
return func(c *CSV) error {
c.i18nLocalizer = i18n.NewLocalizer(c.i18nBundle, "ru")
return nil
}
}