Skip to content

fix(annotate): handle last input line without trailing newline#58

Open
zsbahtiar wants to merge 1 commit intozmap:masterfrom
zsbahtiar:fix/silent-last-line-drop
Open

fix(annotate): handle last input line without trailing newline#58
zsbahtiar wants to merge 1 commit intozmap:masterfrom
zsbahtiar:fix/silent-last-line-drop

Conversation

@zsbahtiar
Copy link

  • Fix silent data loss when input file doesn't end with a trailing newline
  • The last line was skipped because ReadString('\n') returns content alongside io.EOF, and the old loop only processed lines when err == nil

tested:

printf "1.1.1.1\n8.8.8.8" > /tmp/no_newline.txt
cat /tmp/no_newline.txt | go run cmd/zannotate/main.go --geoasn --geoasn-database=./data-snapshots/geolite2_asn.mmdb
{"geoasn":{"asn":13335,"org":"CLOUDFLARENET"},"ip":"1.1.1.1"}
{"geoasn":{"asn":15169,"org":"GOOGLE"},"ip":"8.8.8.8"}

solve: #57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant