On Wed, Aug 23, 2023 at 6:37 AM Phillip Siessl <phillip.sie...@gmx.at>
wrote:

> Hi
>
> i have some issues when i try to download a larger zip file (5GB) via the
> sftp package in go.
> about 20% of the time it runs through smoothly but the other 80% i get a
> panic with
> "fatal error: concurrent map writes writing to file" or "fatal error:
> concurrent map read and map write".
>

There are no map operations in the code you included. The error is
happening somewhere else. The panic should include enough information to
tell where it is coming from.


>
> this is the code for the download function:
>
> func DownloadZip(sc sftp.Client, remoteFile, localFile string) (err error)
> {
>
> fmt.Fprintf(os.Stdout, "Downloading [%s] to [%s] ...\n", remoteFile,
> localFile)
> srcFile, err := sc.OpenFile(remoteFile, (os.O_RDONLY))
> if err != nil {
> fmt.Fprintf(os.Stderr, "Unable to open remote file: %v\n", err)
> return
> }
>
> defer srcFile.Close()
> fmt.Println("Create locale file")
> dstFile, err := os.Create(localFile)
> if err != nil {
> fmt.Fprintf(os.Stderr, "Unable to open local file: %v\n", err)
> return
> }
> defer dstFile.Close()
> fmt.Println("Copy remote file")
> bytes, err := io.Copy(dstFile, srcFile)
> if err != nil {
> fmt.Fprintf(os.Stderr, "Unable to download remote file: %v\n", err)
> os.Exit(1)
> }
> fmt.Println("Save local file")
> fmt.Fprintf(os.Stdout, "%d bytes copied\n", bytes)
>
> return
> }
>
>
> If anybody has some ideas i would be very happy. thx
>
> --
> 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/7afc7aed-a362-4e93-aeec-d5a42005c10cn%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/7afc7aed-a362-4e93-aeec-d5a42005c10cn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAMV2RqrsPjb_dDC66KWOjytfiLi1MkJRqHi51vybmTKvyp7LNQ%40mail.gmail.com.

Reply via email to