Violation of io.Seeker contract
According to Go's io.Seeker documentation:
Seeking to an offset before the start of the file is an error. Seeking to any positive offset may be allowed, but if the new offset exceeds the size of the underlying object, the behavior of subsequent I/O operations is implementation-dependent.
Currently, minio.Object does not respect this contract (its not possible to seek to any positive offset), making it incompatible with standard Go I/O expectations.
How to reproduce
Use tests from standard library testing/iotest. minio.Object returned by GetObject will fail on those tests.
Currently, it fails with:
Seek(-1, 1) from EOF = 0, Negative position not allowed for 1, want 39, nil
The issue likely originates here:
|
if offset < 0 && whence != 2 { |
Since testing/iotest is part of the standard Go library, this behavior prevents minio.Object from being safely used in other libraries that rely on standard I/O behavior.
Proposed solution:
// Negative offset not valid for whence of '0'.
if offset < 0 && whence == 0 {
return 0, errInvalidArgument("Negative position not allowed for 0")
}
Violation of
io.SeekercontractAccording to Go's
io.Seekerdocumentation:Currently, minio.Object does not respect this contract (its not possible to seek to any positive offset), making it incompatible with standard Go I/O expectations.
How to reproduce
Use tests from standard library
testing/iotest.minio.Objectreturned byGetObjectwill fail on those tests.Currently, it fails with:
The issue likely originates here:
minio-go/api-get-object.go
Line 539 in 60b85ef
Since
testing/iotestis part of the standard Go library, this behavior preventsminio.Objectfrom being safely used in other libraries that rely on standard I/O behavior.Proposed solution: