]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Make the package example an actual example.
authorMatt Joiner <anacrolix@gmail.com>
Sun, 24 May 2015 11:36:24 +0000 (21:36 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Sun, 24 May 2015 11:36:24 +0000 (21:36 +1000)
I can't remember who had this great suggestion.

doc.go
example_test.go [new file with mode: 0644]

diff --git a/doc.go b/doc.go
index f8670a967d500d3e918a138fa1017dde5286a14e..d6b42e789bdea7f913dd8396abaf8d1835e0f099 100644 (file)
--- 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 (file)
index 0000000..02655e9
--- /dev/null
@@ -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")
+}