Re: [go-nuts] cannot convert fs.FS zip file to io.ReadSeeker (missing Seek)

2022-09-21 Thread Matthew Zimmerman
I've got this same challenge. The contents of any file within a zip needs to be read as a stream, hence why there is no underlying seek method available (assuming to handle the decompression properly) So if you want to seek in a file within a zip, you need to read into a buffer first. You don't h

[go-nuts] Re: Question on 'src/internal/singleflight': The return result of the ForgetUnshared method seems to be inaccurate

2022-09-21 Thread atomic
> Also notice that the random time you pick for cancelTime can be longer than the different random time you sleep inside the goroutine (i.e. the function which you pass to DoChan). Hence the goroutine can return a result, before the cancelTime is reached. Although the goroutine can return a re

Re: [go-nuts] cannot convert fs.FS zip file to io.ReadSeeker (missing Seek)

2022-09-21 Thread robert engels
Yea - my bad. Should be fine. > On Sep 21, 2022, at 7:56 PM, 'Dan Kortschak' via golang-nuts > wrote: > > On Wed, 2022-09-21 at 19:30 -0500, robert engels wrote: >> Others have suggested passing a ByteBuffer - I don’t think that will >> work because you will be missing other methods that are pr

Re: [go-nuts] cannot convert fs.FS zip file to io.ReadSeeker (missing Seek)

2022-09-21 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2022-09-21 at 19:30 -0500, robert engels wrote: > 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) The function that was pointed to takes an ~io.ReadSeeker (oddly

Re: [go-nuts] cannot convert fs.FS zip file to io.ReadSeeker (missing Seek)

2022-09-21 Thread robert engels
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 wrote: > > fs.FS does not support positional reads. It is always the entire

Re: [go-nuts] cannot convert fs.FS zip file to io.ReadSeeker (missing Seek)

2022-09-21 Thread robert engels
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 > wrote: > > I have a program that needs to wo

[go-nuts] Re: cannot convert fs.FS zip file to io.ReadSeeker (missing Seek)

2022-09-21 Thread Anthony Martin
Rory Campbell-Lange once said: > interface conversion: *zip.checksumReader is not io.ReadSeeker: > missing method Seek > > Advice on how to rectify this would be gratefully received. Read the entire zip.File into memory with io.ReadAll and create a bytes.Reader with the resulting byte slice. That

Re: [go-nuts] cannot convert fs.FS zip file to io.ReadSeeker (missing Seek)

2022-09-21 Thread 'Dan Kortschak' via golang-nuts
On Thu, 2022-09-22 at 00:58 +0100, Rory Campbell-Lange wrote: > interface conversion: *zip.checksumReader is not io.ReadSeeker: > missing method Seek > > Advice on how to rectify this would be gratefully received. Would it be acceptable to conditionally copy the reader's contents into a buffer tha

[go-nuts] cannot convert fs.FS zip file to io.ReadSeeker (missing Seek)

2022-09-21 Thread Rory Campbell-Lange
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 co

[go-nuts] Error-checking with errors.As() is brittle with regards to plain vs pointer types

2022-09-21 Thread cpu...@gmail.com
Consider https://go.dev/play/p/jgPMwLRRsqe: errors.As(err, ) will not match if error is of pointer type. As a result, a library consumer needs to understand if a library returns Error or *Error. However, that is not part of the API spec as both returns would satisfy error if Error() is implemen

Re: [go-nuts] Re: Question on 'cmd/compile: handle partially overlapping assignments' behavior on ARM64.

2022-09-21 Thread Josh Peterson
I am going to open an issue for this regression on ARM64 unless there are objections or a view that this is the intended behavior. Josh On Tuesday, September 20, 2022 at 3:04:00 PM UTC-4 ccie...@gmail.com wrote: > Hi Peter, > > Please note that versions devel *go1.20-bcd44b61d3*, *1.19.1*, and

[go-nuts] Re: Question on 'src/internal/singleflight': The return result of the ForgetUnshared method seems to be inaccurate

2022-09-21 Thread Brian Candler
Notice that DoChan starts a goroutine for the task... go g.doCall(c, key, fn) ... and then returns immediately. Also notice that the random time you pick for cancelTime can be longer than the different random time you sleep inside the goroutine (i.e. the function which you pass to DoCh

[go-nuts] Re: Question on 'src/internal/singleflight': The return result of the ForgetUnshared method seems to be inaccurate

2022-09-21 Thread atomic
Thanks for your reply, but I still don't understand why time.Sleep is causing my test program to panic. In fact, this is a real online environment problem. My application uses http.Client.Do(), but it occasionally has errors: [lookup x on x: dial udp x: operation was canceled], afte

[go-nuts] Re: Question on 'src/internal/singleflight': The return result of the ForgetUnshared method seems to be inaccurate

2022-09-21 Thread Cuong Manh Le
Hello, You use time.Sleep in your program, so the behavior is not predictable. In fact, I get it success or panic randomly. You can see https://go-review.googlesource.com/c/sync/+/424114 to see a predictable test of ForgetUnshared . On Wednesday, September 21, 2022 at 1:45:24 PM UTC+7 atomic w