Others have suggested passing a ByteBuffer - I don’t think that will work 
because you will be missing other methods that are probably needed (FileInfo to 
get the name, etc)

> On Sep 21, 2022, at 7:26 PM, robert engels <reng...@ix.netcom.com> wrote:
> 
> fs.FS does not support positional reads. It is always the entire file.
> 
> You can create a wrapper struct that implements the Seek() (trivial - just 
> keep a position and adjust Read() accordingly).
> 
> 
> 
>> On Sep 21, 2022, at 6:58 PM, Rory Campbell-Lange <r...@campbell-lange.net> 
>> wrote:
>> 
>> I have a program that needs to work equally for a directory of files or for 
>> the contents of a zip file, so I'm using an fs.FS to abstract the two. 
>> 
>> Some of the files need to be provided to a PDF importer that accepts an 
>> io.ReadSeeker (#1).
>> 
>> Generally this is working fine except when trying to convert a zip file to 
>> an io.ReadSeeker. Concisely:
>> 
>>    1     package main
>>    2 
>>    3     import (
>>    4         "archive/zip"
>>    5         "fmt"
>>    6         "io"
>>    7     )
>>    8 
>>    9     func main() {
>>   10         z, _ := zip.OpenReader("a.zip")
>>   11         a, _ := z.Open("a") // a is a file in a.zip
>>   12         f, _ := a.Stat()
>>   13         fmt.Println(f.Name() == "a") // true
>>   14         fmt.Println(a.(io.ReadSeeker))
>>   15     }
>> 
>> Fails on line 14 with
>> 
>> interface conversion: *zip.checksumReader is not io.ReadSeeker: missing 
>> method Seek
>> 
>> Advice on how to rectify this would be gratefully received.
>> 
>> #1
>> https://github.com/phpdave11/gofpdf/blob/b09d9214a2296c8ea10312d9c5a520e27f2148c9/contrib/gofpdi/gofpdi.go#L52
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to golang-nuts+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/YyulHNPauBLiO%2BWa%40campbell-lange.net.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/F7077245-5B74-4363-A48E-D6E870513CF2%40ix.netcom.com.

Reply via email to