Hello Together,
i am a go beginner and i am coming from germany, and i hope you can help me.
In the moment i am working on a little backup/copy program. Nothing special, only copy.
You can find the code-snippet here: https://play.golang.org/p/vhBunDg92V
There ist nothing magic in the whole Programm, a litte bit more as the snippet.
(For example before copy, making the Folder …)
The Implementation of the FileOpener interface makes a os.Open(filename) and os.Stat(filename) and a Checksum, and give the ReadCloser Interface inside the File back.
The Implementation of the FileWriter interface makes a http Post Request with the file as body input.
The whole program works ok.
Also when i copy bigger files, for example 1GB, the program needs not more than 10MB, very Nice.
Only working with the ReaderCloser Interface
func copyFileNormal(opener FileOpener, writer FileWriter, src, dst string) error {…}
Now i was a litte bit experience with buffering the file first before to write.
func copyFileBuffered(opener FileOpener, writer FileWriter, src, dst string) error {…}
How i do this ?
Depends on the version inside the function, the program needs now 3 * file size of memory
When i now copy a file with 1GB the Program needs now 3GB, not so good.
The whole file size with little bit overhead is ok, but not 2 * or 3 * of the file size.
What do i wrong ?
Or is that a normal behavior of the GC ?
Which Version is the best or is the a better solution ?
Or what is the problem here ?
Greets and Thanks
Michael