From f6ea696df66d8e1d5a86668bd61e10ff0e33b8a9 Mon Sep 17 00:00:00 2001 From: kercylan98 Date: Wed, 29 Nov 2023 16:24:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20ReadLineWithParalle?= =?UTF-8?q?l=20=E5=BD=93=E8=AF=BB=E5=8F=96=E5=88=B0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=B0=BE=E6=97=B6=EF=BC=8C=E8=BF=94=E5=9B=9E=E7=9A=84=20offset?= =?UTF-8?q?=20=E6=9C=89=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/file/file.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utils/file/file.go b/utils/file/file.go index 7f6ae98..eddb77b 100644 --- a/utils/file/file.go +++ b/utils/file/file.go @@ -163,6 +163,11 @@ func ReadLineWithParallel(filename string, chunkSize int64, handlerFunc func(str _ = file.Close() }() + fileSize, err := file.Seek(0, io.SeekEnd) + if err != nil || offset-1 >= fileSize { + return offset, err + } + chunks := FindLineChunksByOffset(file, offset, chunkSize) var end int64 var endMutex sync.Mutex