]> Sergey Matveev's repositories - btrtrc.git/blob - example_test.go
Merge pull request #72 from shoenig/magnetize
[btrtrc.git] / example_test.go
1 package torrent_test
2
3 import (
4         "log"
5
6         "github.com/anacrolix/missinggo"
7
8         "github.com/anacrolix/torrent"
9 )
10
11 func Example() {
12         c, _ := torrent.NewClient(nil)
13         defer c.Close()
14         t, _ := c.AddMagnet("magnet:?xt=urn:btih:ZOCMZQIPFFW7OLLMIC5HUB6BPCSDEOQU")
15         <-t.GotInfo()
16         t.DownloadAll()
17         c.WaitAll()
18         log.Print("ermahgerd, torrent downloaded")
19 }
20
21 func Example_fileReader() {
22         var (
23                 t *torrent.Torrent
24                 f torrent.File
25         )
26         r := t.NewReader()
27         defer r.Close()
28         // Access the parts of the torrent pertaining to f. Data will be
29         // downloaded as required, per the configuration of the torrent.Reader.
30         _ = missinggo.NewSectionReadSeeker(r, f.Offset(), f.Length())
31 }