From c1e0d071a6206203cfeb44ae03868ea5815d49d0 Mon Sep 17 00:00:00 2001 From: Leonid Nikitin Date: Sat, 14 Mar 2026 11:41:24 +0500 Subject: [PATCH] Add comments to JSON Lines parser for improved documentation --- parser/json_lines.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/parser/json_lines.go b/parser/json_lines.go index c67f192..2192a04 100644 --- a/parser/json_lines.go +++ b/parser/json_lines.go @@ -7,12 +7,14 @@ import ( "strings" ) +// jsonLinesExtract defines the function signature for extracting IP addresses from a JSON Lines item. type jsonLinesExtract func(item json.RawMessage) (string, error) type jsonLinesParser struct { extract jsonLinesExtract } +// NewJsonLines creates a new JSON Lines parser. func NewJsonLines(extract jsonLinesExtract) (Parser, error) { if extract == nil { return nil, fmt.Errorf("json lines extract is nil") @@ -23,6 +25,8 @@ func NewJsonLines(extract jsonLinesExtract) (Parser, error) { }, nil } +// Parse parses the JSON Lines data from the given reader. +// It returns a slice of IP addresses and any errors that occurred during the process. func (p *jsonLinesParser) Parse(body io.Reader, validator IPValidator, limit uint) (IPs, error) { decoder := json.NewDecoder(body) ips := make(IPs, 0)