Recently, I have been using this project(github.com/anacrolix/torrent). Specifically, it's a library. I use the cmd/torrent module in it to learn how this library works.
The command is like this:
cd cmd/torrent
go mod init torrentmain
go mod tidy
go build
./torrentmain download The.Mandalorian.S03E06.WEB.x264-TORRENTGALAXY.torrent
I got a few questions when I was debugging.
The download.go/downloadErr function calls the addTorrents function, which marks the entire torrent to be downloaded by calling t.DownloadAll().
As the t.DownloadAll() just announces which pieces should be downloaded, the actual download work is done by some goroutines (I guess) and I couldn't know how it works.
What I would like to know is in which submodule it downloads data and how it downloads data.
My final purpose is to make the downloaded file saved in the memory directly and not stored in the disk. So I need to know in which submodule it downloads data and how it downloads data.