0f0bf1752dd7f602f944600d938afdc8bcc91e44

Author
TheEdgeOfRage <git@theedgeofrage.com>
Committer
TheEdgeOfRage <git@theedgeofrage.com>
Date

Message

Fix default buffer size config

Diff

 1diff --git a/config/config.go b/config/config.go
 2index b1cb1a472c525c1ac91c618723a04baaea4f93a1..2d3d216f0f838b7be468df31ca9872bbbe530ce6 100644
 3--- a/config/config.go
 4+++ b/config/config.go
 5@@ -49,7 +49,7 @@ type rawConfig struct {
 6 	KeepEmpty     bool   `long:"keep-empty" short:"k" description:"Keep lines with no field present selected by output or with all excluded"` // nolint:lll
 7 	Raw           bool   `long:"raw" short:"r" description:"Output only selected fields values (comma separated) lcut like"`                  // nolint:lll
 8 	All           bool   `long:"all" short:"A" description:"Output all field after the output fields effectivly making it ordered"`           // nolint:lll
 9-	BufferSize    int    `long:"buffer-size" short:"B" description:"How long should a line be expected to be?" default:"1048576"`
10+	BufferSize    int    `long:"buffer-size" short:"B" description:"How long should a line be expected to be?" default:"1048576"`             // nolint:lll
11 }
12 
13 func Parse() (*Config, error) {
14diff --git a/parser/parser.go b/parser/parser.go
15index fd08b23b1b93db1f9d95e7d0b76049d44a79399a..cd00546bb4a730135884cd21ffc333210c027b0d 100644
16--- a/parser/parser.go
17+++ b/parser/parser.go
18@@ -17,6 +17,9 @@ type Parser struct {
19 }
20 
21 func NewParser(cfg *config.Config, input io.Reader, output io.Writer) *Parser {
22+	if cfg.BufferSize == 0 {
23+		cfg.BufferSize = 1048576
24+	}
25 	return &Parser{
26 		cfg:    cfg,
27 		input:  input,