You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Go (as of 1.9 at least) reports os.Stdin as an io.Seeker, however when receiving stdin as a pipe, any seek attempt later on will fail. In msgp's case this breaks when valid input is being piped in.
I've whipped up an extra check that tries to detect this situation and fallback to non-io.Seeker appropriately.
Great find. Looking at it, it seems like the standard library conflates the UNIX file descriptor concept with the file concept. Standard input does represent a file descriptor, but the standard library, for convenience, calls that an os.File, and Go's os.File struct are all, by definition implement the io.Seeker interface. From os/file.go:
var (
Stdin=NewFile(uintptr(syscall.Stdin), "/dev/stdin")
Stdout=NewFile(uintptr(syscall.Stdout), "/dev/stdout")
Stderr=NewFile(uintptr(syscall.Stderr), "/dev/stderr")
)
Go (as of 1.9 at least) reports os.Stdin as an io.Seeker, however when receiving stdin as a pipe, any seek attempt later on will fail. In msgp's case this breaks when valid input is being piped in.
I've whipped up an extra check that tries to detect this situation and fallback to non-io.Seeker appropriately.
patch-stdin-seeker-workaround.txt
The text was updated successfully, but these errors were encountered: