func-os.go: fixed the handling of err==io.EOF
This commit is contained in:
parent
be874503ec
commit
d657cbb51e
@ -126,7 +126,7 @@ func writeFileFunc(ctx ExprContext, name string, args []any) (result any, err er
|
||||
|
||||
func readFileFunc(ctx ExprContext, name string, args []any) (result any, err error) {
|
||||
var handle osHandle
|
||||
|
||||
result = nil
|
||||
if len(args) > 0 {
|
||||
handle, _ = args[0].(osHandle)
|
||||
}
|
||||
@ -141,13 +141,16 @@ func readFileFunc(ctx ExprContext, name string, args []any) (result any, err err
|
||||
limit = s[0]
|
||||
}
|
||||
}
|
||||
if v, err = r.reader.ReadString(limit); err == nil || err == io.EOF {
|
||||
if v, err = r.reader.ReadString(limit); err == nil {
|
||||
if len(v) > 0 && v[len(v)-1] == limit {
|
||||
result = v[0 : len(v)-1]
|
||||
} else {
|
||||
result = v
|
||||
}
|
||||
}
|
||||
if err == io.EOF {
|
||||
err = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user