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
func t(filePath string) { c, err := ftp.Dial(ftpServer, ftp.DialWithTimeout(5*time.Second)) if err != nil { log.Fatal(fmt.Sprintf("filePath: %s err: %v", filePath, err)) } err = c.Login(ftpUser, ftpPasswd) if err != nil { log.Fatal(fmt.Sprintf("filePath: %s err: %v", filePath, err)) } for i := 0; i < 5; i++ { _, err := c.Retr(filePath) if err != nil { log.Fatal(fmt.Sprintf("filePath: %s err: %v", filePath, err)) } } if err := c.Quit(); err != nil { log.Fatal(err) } }
The text was updated successfully, but these errors were encountered:
The package version is github.com/jlaffaye/ftp v0.2.0
Sorry, something went wrong.
It's because you're not closing the file. Try this:
func t(filePath string) { conn, err := ftp.Dial(ftpServer, ftp.DialWithTimeout(5*time.Second)) if err != nil { log.Fatal(fmt.Sprintf("filePath: %s err: %v", filePath, err)) } if err = conn.Login(ftpUser, ftpPasswd); err != nil { log.Fatal(fmt.Sprintf("filePath: %s err: %v", filePath, err)) } for i := 0; i < 5; i++ { // pull file resp, err := conn.Retr(filePath) if err != nil { log.Fatal(fmt.Sprintf("filePath: %s err: %v", filePath, err)) } // do something with the file // close the file if err = resp.Close(); err != nil { log.Fatal(err) } } if err = conn.Quit(); err != nil { log.Fatal(err) } }
No branches or pull requests
The text was updated successfully, but these errors were encountered: