Documentation ¶
Index ¶
- func Marshal(v interface{}) ([]byte, error)
- func MustMarshal(v interface{}) []byte
- func Unmarshal(data []byte, v interface{}) (err error)
- type Bytes
- type Decoder
- type Encoder
- type ErrUnusedTrailingBytes
- type MarshalTypeError
- type Marshaler
- type MarshalerError
- type SyntaxError
- type UnmarshalFieldError
- type UnmarshalInvalidArgError
- type UnmarshalTypeError
- type Unmarshaler
- type UnmarshalerError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Marshal ¶
Marshal the value 'v' to the bencode form, return the result as []byte and an error if any.
func MustMarshal ¶
func MustMarshal(v interface{}) []byte
Types ¶
type Decoder ¶
type Decoder struct { // Sum of bytes used to Decode values. Offset int64 // contains filtered or unexported fields }
func NewDecoder ¶
type ErrUnusedTrailingBytes ¶
type ErrUnusedTrailingBytes struct {
NumUnusedBytes int
}
func (ErrUnusedTrailingBytes) Error ¶
func (me ErrUnusedTrailingBytes) Error() string
type MarshalTypeError ¶
In case if marshaler cannot encode a type, it will return this error. Typical example of such type is float32/float64 which has no bencode representation.
func (*MarshalTypeError) Error ¶
func (e *MarshalTypeError) Error() string
type Marshaler ¶
Any type which implements this interface, will be marshaled using the specified method.
type MarshalerError ¶
A non-nil error was returned after calling MarshalBencode on a type which implements the Marshaler interface.
func (*MarshalerError) Error ¶
func (e *MarshalerError) Error() string
type SyntaxError ¶
Malformed bencode input, unmarshaler failed to parse it.
func (*SyntaxError) Error ¶
func (e *SyntaxError) Error() string
type UnmarshalFieldError ¶
type UnmarshalFieldError struct { Key string Type reflect.Type Field reflect.StructField }
Unmarshaler tried to write to an unexported (therefore unwritable) field.
func (*UnmarshalFieldError) Error ¶
func (e *UnmarshalFieldError) Error() string
type UnmarshalInvalidArgError ¶
Unmarshal argument must be a non-nil value of some pointer type.
func (*UnmarshalInvalidArgError) Error ¶
func (e *UnmarshalInvalidArgError) Error() string
type UnmarshalTypeError ¶
Unmarshaler spotted a value that was not appropriate for a given Go value.
func (*UnmarshalTypeError) Error ¶
func (e *UnmarshalTypeError) Error() string
type Unmarshaler ¶
Any type which implements this interface, will be unmarshaled using the specified method.
type UnmarshalerError ¶
A non-nil error was returned after calling UnmarshalBencode on a type which implements the Unmarshaler interface.
func (*UnmarshalerError) Error ¶
func (e *UnmarshalerError) Error() string