A Go library that reads the last line of a text file
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
James Mills af293d63a6
Move to git.mills.io
1 year ago
.idea init 2 years ago
cmd/read-file-last-line Add offset to ReadLastLine() + unit tests 2 years ago
testdata Fix bug if the file only contains one line 2 years ago
LICENSE Initial commit 2 years ago
README.md update 2 years ago
go.mod Move to git.mills.io 1 year ago
go.sum Fix import 2 years ago
read-file-last-line Add offset to ReadLastLine() + unit tests 2 years ago
read.go Fix bug if the file only contains one line 2 years ago
read_test.go Fix bug if the file only contains one line 2 years ago

README.md

read-file-last-line

read-file-last-line

step

  1. open file and get file size

  2. readAt() form file end,

  3. loop

    • read file like pieces, size from 64byte to 128byte to 256byte ...
    • put contents to bytes.Buffer
    • record content length

    until find line break

  4. reassemble contents, like from [e,d,bc,a] to [a,bc,d,e]