magneturi is a library for parsing magnet URI into go struct.

Go Reference x codecov Go Report Card


Installation

go get github.com/go-bittorrent/magneturi

Example

package main

import (
	"fmt"

	"github.com/go-bittorrent/magneturi"
)

func main() {
	parsed, err := magneturi.Parse("magnet:?xt=urn:btih:9b4c1489bfccd8205d152345f7a8aad52d9a1f57&dn=archlinux-2022.05.01-x86_64.iso")
	if err != nil {
		panic(err)
	}

	fmt.Println(parsed.Encoded()) // magnet:?dn=archlinux-2022.05.01-x86_64.iso&xt=urn:btih:9b4c1489bfccd8205d152345f7a8aad52d9a1f57
}

License

MIT

GitHub

View Github