Documentation
¶
Index ¶
- Constants
- Variables
- func DecodeInt(r io.Reader) (int, error)
- func DecodeString(r io.Reader) (string, error)
- func EncodeInt(w io.Writer, val int) (int, error)
- func EncodeString(w io.Writer, val string) (int, error)
- func GetValue[T allowedTypes](o *BObject, dest *T) error
- func Marshal(w io.Writer, s any) (int, error)
- func Unmarshal(r io.Reader, s any) error
- func UnmarshalBObject(o *BObject, s any) error
- type BObject
- type BType
Constants ¶
View Source
const ( BENCODE_TAG = "bencode" // 解析结构体上的 TAG 标签 IGNORE_TAG_VALUE = "-" // 忽略结构体上的字段 )
Variables ¶
View Source
var ( ErrBType = errors.New("error BObject type") // 非法 BObject 类型 ErrInvalidBObject = errors.New("invalid BObject encoding") // 非法 BObject 编码 ErrInvalidStringFormat = errors.New("invalid string format") // 非法字符串格式 ErrInvalidIntFormat = errors.New("invalid int format") // 非法整数格式 ErrMissingDigits = errors.New("missing digits after sign") // 正负号后缺少数字 ErrStringLength = errors.New("invalid string length prefix") // 字符串长度非法 ErrNoPtr = errors.New("dest must be a pointer") // 传递参数非指针类型 ErrSrcMustBeStructOrSlice = errors.New("src code must be struct or slice") // 被绑定的必须是结构体或者切片 ErrDestMustBeSlice = errors.New("dest must be pointer to slice") // 目标必须是切片指针 ErrType = errors.New("error type") // 类型错误 )
Functions ¶
func EncodeString ¶
编码写入一个字符串 写入"Hello World" -> "11:Hello World"
Types ¶
Click to show internal directories.
Click to hide internal directories.