bencode

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2021 License: MIT Imports: 10 Imported by: 0

README

Bencode

JetBrains Open Source Licenses GoDoc Sourcegraph Go Report Card Release MIT license

Example

package main

import (
	"fmt"
	
	"go.x2ox.com/bencode"
)

func main() {
	s1 := "this is a example"
	b, err := bencode.Marshal(&s1)
	if err != nil {
		return
	}
	fmt.Println(string(b))
	
	var s2 string
	if err = bencode.Unmarshal(b, &s2); err != nil {
		return
	}
	fmt.Println(s2)
}

TODO

  • Coverage test

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(v interface{}) ([]byte, error)

func Unmarshal

func Unmarshal(data []byte, v interface{}) error

Types

type Error

type Error error

type Marshaler

type Marshaler interface {
	MarshalBencode() ([]byte, error)
}

Marshaler is the interface implemented by types that can marshal themselves into valid JSON.

type Unmarshaler

type Unmarshaler interface {
	UnmarshalBencode([]byte) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL