]> 127.0.0.1 Git - part/.git/commitdiff
fix v0.10.8
authorqydysky <32743305+qydysky@users.noreply.github.com>
Sun, 16 Oct 2022 04:47:18 +0000 (12:47 +0800)
committerqydysky <32743305+qydysky@users.noreply.github.com>
Sun, 16 Oct 2022 04:47:18 +0000 (12:47 +0800)
file/FileWR.go
file/FileWR_test.go

index f021e48d8cbd0b9a2bed387df54b2654be060f3d..063b6a110ad3737c44e5b5a3cf992d9ffa9a8c13 100644 (file)
@@ -127,11 +127,9 @@ func (t *File) ReadUntil(separation byte, perReadSize int, maxReadSize int) (dat
                n, e = t.read().Read(tmpArea)
 
                if n == 0 && e != nil {
-                       if errors.Is(e, io.EOF) {
-                               e = nil
-                       }
                        return
                }
+
                maxReadSize = maxReadSize - n
 
                if i := bytes.Index(tmpArea[:n], []byte{separation}); i != -1 {
index 475357737ceffa029b542790bd7049a1e97b47a6..801c0ee2e7a285a25c7760fc3b8112c4fbe54744 100644 (file)
@@ -2,6 +2,8 @@ package part
 
 import (
        "bytes"
+       "errors"
+       "io"
        "testing"
 
        "golang.org/x/text/encoding/simplifiedchinese"
@@ -156,6 +158,12 @@ func TestReadUntil(t *testing.T) {
                t.Fatal(string(data))
        }
 
+       if data, e := f.ReadUntil('\n', 5, 20); e == nil || !errors.Is(e, io.EOF) {
+               t.Fatal(e)
+       } else {
+               t.Log(string(data))
+       }
+
        if e := f.Close(); e != nil {
                t.Fatal(e)
        }