github.com/anacrolix/torrent@v1.61.0/example_test.go (about) 1 package torrent_test 2 3 import ( 4 "log" 5 6 "github.com/anacrolix/torrent" 7 ) 8 9 func Example() { 10 c, _ := torrent.NewClient(nil) 11 defer c.Close() 12 t, _ := c.AddMagnet("magnet:?xt=urn:btih:ZOCMZQIPFFW7OLLMIC5HUB6BPCSDEOQU") 13 <-t.GotInfo() 14 t.DownloadAll() 15 c.WaitAll() 16 log.Print("ermahgerd, torrent downloaded") 17 } 18 19 func Example_fileReader() { 20 var f torrent.File 21 // Accesses the parts of the torrent pertaining to f. Data will be 22 // downloaded as required, per the configuration of the torrent.Reader. 23 r := f.NewReader() 24 defer r.Close() 25 }