Skip to content

BUG: last input line silently dropped when file doesn't end with newline #57

@zsbahtiar

Description

@zsbahtiar

AnnotateRead in annotate.go uses ReadString('\n') in a loop that only processes lines when err == nil. If the last line of input doesn't end with \n, ReadString returns the line content together with io.EOF, and the loop skips it — silently dropping the last record

printf "1.1.1.1\n8.8.8.8" > /tmp/no_newline.txt
cat /tmp/no_newline.txt | zannotate --geoasn --geoasn-database=path/to/db.mmdb

actual

{"ip":"1.1.1.1","geoasn":{"asn":13335,"org":"CLOUDFLARENET"}}

want

{"ip":"1.1.1.1","geoasn":{"asn":13335,"org":"CLOUDFLARENET"}}
{"ip":"8.8.8.8","geoasn":{"asn":15169,"org":"GOOGLE"}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions