From: Matt Joiner Date: Sun, 24 May 2015 11:36:24 +0000 (+1000) Subject: Make the package example an actual example. X-Git-Tag: v1.0.0~1176 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=7f8ce59e39dda941a0e1039e862ec5b74c16f82a;p=btrtrc.git Make the package example an actual example. I can't remember who had this great suggestion. --- diff --git a/doc.go b/doc.go index f8670a96..d6b42e78 100644 --- a/doc.go +++ b/doc.go @@ -1,16 +1,3 @@ -/* -Package torrent implements a torrent client. +// Package torrent implements a torrent client. -Simple example: - - c, _ := torrent.NewClient(&torrent.Config{}) - defer c.Close() - t, _ := c.AddMagnet("magnet:?xt=urn:btih:ZOCMZQIPFFW7OLLMIC5HUB6BPCSDEOQU") - <-t.GotInfo - t.DownloadAll() - c.WaitAll() - log.Print("ermahgerd, torrent downloaded") - - -*/ package torrent diff --git a/example_test.go b/example_test.go new file mode 100644 index 00000000..02655e95 --- /dev/null +++ b/example_test.go @@ -0,0 +1,17 @@ +package torrent_test + +import ( + "log" + + "github.com/anacrolix/torrent" +) + +func Example() { + c, _ := torrent.NewClient(&torrent.Config{}) + defer c.Close() + t, _ := c.AddMagnet("magnet:?xt=urn:btih:ZOCMZQIPFFW7OLLMIC5HUB6BPCSDEOQU") + <-t.GotInfo() + t.DownloadAll() + c.WaitAll() + log.Print("ermahgerd, torrent downloaded") +}