I use github.com/pkg/sftp for work with a sftp server in golang.
I want to download file from sftp server.
For that i need to get bytes of this file and copy it to a local file right?
First i get my file with a OpenFile function :
file, err := sc.OpenFile("/backup/" serverid "/" f.Name())
if err != nil {
fmt.Fprintf(os.Stderr, "Unable to open file: %v\n", err)
return err
}
myfiles, err := file.HERE()
os.WriteFile("/text.txt", myfiles, perm)
return nil
But after i need to get bytes of this file but how i can do that? What should i enter instead of HERE?
CodePudding user response:
Resolved with:
myfile, err := io.ReadAll(file)
