Skip to content

Commit feab0da

Browse files
committed
Embed WriterOptions into writer
1 parent 3ea11fc commit feab0da

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

writer.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ type WriterOptions struct {
4747
}
4848

4949
func Write(src []byte, opts WriterOptions) string {
50-
w := writer{opts: opts}
50+
w := writer{WriterOptions: opts}
5151

5252
for len(src) > 0 {
5353
w.newLine()
@@ -100,7 +100,7 @@ type groupInfo struct {
100100
}
101101

102102
type writer struct {
103-
opts WriterOptions
103+
WriterOptions
104104
lines []line
105105
groups stack[groupInfo]
106106
}
@@ -182,7 +182,7 @@ func (w *writer) decodeField(src []byte) ([]byte, bool) {
182182
src = rest
183183

184184
// 0 is never a valid field number, so this probably isn't a message.
185-
if value>>3 == 0 && !w.opts.AllFieldsAreMessages {
185+
if value>>3 == 0 && !w.AllFieldsAreMessages {
186186
return nil, false
187187
}
188188

@@ -346,7 +346,7 @@ func (w *writer) decodeField(src []byte) ([]byte, bool) {
346346
// consumed *some* bytes, and the user requested unconditional message
347347
// parsing, we'll continue regardless. We don't bother in the case where we
348348
// failed at the start because the `...` case below will do a cleaner job.
349-
if len(src2) == 0 || (w.opts.AllFieldsAreMessages && len(src2) < len(delimited)) {
349+
if len(src2) == 0 || (w.AllFieldsAreMessages && len(src2) < len(delimited)) {
350350

351351
oneLiner := false
352352
if len(src2) > 0 {
@@ -369,7 +369,7 @@ func (w *writer) decodeField(src []byte) ([]byte, bool) {
369369
}
370370

371371
// Otherwise, maybe it's a UTF-8 string.
372-
if !w.opts.NoQuotedStrings && utf8.Valid(delimited) {
372+
if !w.NoQuotedStrings && utf8.Valid(delimited) {
373373
runes := utf8.RuneCount(delimited)
374374

375375
s := string(delimited)

0 commit comments

Comments
 (0)