We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If length is required, maybe consider a different interface like fs.File or you could declare an interface like
fs.File
type LengthReader interface { io.Reader Len() int }
which is satisfied by bytes.Buffer and strings.Reader and provide a helper for os.File/fs.File like
bytes.Buffer
strings.Reader
os.File/fs.File
type lr struct { fs.File } func (lr *r) Len() int { info, err := r.Stat() if err != nil { panic(err) // or ignore/log } return int(info.Size()) } // LengthReaderFromFile returns a LengthReader from an fs.File func LengthReaderFromFile(f fs.File) LengthReader { return &lr{f} }
Originally posted by @micahhausler in #261 (comment)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
If length is required, maybe consider a different interface like
fs.File
or you could declare an interface likewhich is satisfied by
bytes.Buffer
andstrings.Reader
and provide a helper foros.File/fs.File
likeOriginally posted by @micahhausler in #261 (comment)
The text was updated successfully, but these errors were encountered: