Skip to content

whoisdinanath/torrent-client.go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

torrentClient

torrentClient is (wip) a Go library for marshalling and unmarshalling BitTorrent bencode data into Go structs using reflection.

Features

  • Encode Go structs to bencode format
  • Decode bencode data to Go structs
  • Utilizes Go's reflection capabilities

Installation

To install TorrentClient, use go get:

go get github.com/yourusername/torrentclient

Usage

Here's a basic example of how to use TorrentClient:

package main

import (
	"fmt"
	"github.com/yourusername/torrentclient"
)

func main() {
	// Example struct
	type Torrent struct {
		Announce string
		Info     struct {
			Name   string
			Length int
		}
	}

	// Decode bencode data
	var t Torrent
	err := bencoder.Unmarshal([]byte("d8:announce13:http://...e"), &t)
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	fmt.Println("Decoded:", t)

	// Encode struct to bencode
	data, err := bencoder.Marshal(t)
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	fmt.Println("Encoded:", string(data))
}

Contributing

Contributions are welcome! Please submit a pull request or open an issue to discuss your changes.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

bitTorrent client implementation in Golang for gaining a bit more knowledge on how torrent works and also Golang following AsliEngineering Tutorials.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages