github.com/anacrolix/torrent@v1.61.0/tests/issue-798/main.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  
     6  	app "github.com/anacrolix/gostdapp"
     7  
     8  	"github.com/anacrolix/torrent"
     9  )
    10  
    11  func main() {
    12  	app.Run(mainErr)
    13  }
    14  
    15  func mainErr() error {
    16  	config := torrent.NewDefaultClientConfig()
    17  	config.DataDir = "./output"
    18  	config.ListenPort = 0
    19  	c, err := torrent.NewClient(config)
    20  	if err != nil {
    21  		return err
    22  	}
    23  	defer c.Close()
    24  	t, _ := c.AddMagnet("magnet:?xt=urn:btih:99c82bb73505a3c0b453f9fa0e881d6e5a32a0c1&tr=https%3A%2F%2Ftorrent.ubuntu.com%2Fannounce&tr=https%3A%2F%2Fipv6.torrent.ubuntu.com%2Fannounce")
    25  	<-t.GotInfo()
    26  	fmt.Println("start downloading")
    27  	t.DownloadAll()
    28  	c.WaitAll()
    29  	return nil
    30  }