Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
github.com/gdm85/go-rencode
go-rencode is a Go implementation of aresch/rencode.
The rencode logic is similar to bencode. For complex, heterogeneous data structures with many small elements, r-encodings take up significantly less space than b-encodings.
Example of encoder construction and use:
b := bytes.Buffer{}
e := rencode.NewEncoder(&b)
err := e.Encode(100, true, "hello world", rencode.NewList(42, "nesting is awesome"), 3.14, rencode.Dictionary{})
You can use either specific methods to encode one of the supported types, or the interface-generic Encode()
method.
Example of decoder construction:
e := rencode.NewDecoder(&b)
The DecodeNext()
method can be used to decode the next value from the rencode stream; however this method returns an interface{}
while it is usually the norm that there is an expected type instead; in such cases, it is advised to use the Scan()
method instead,
which accepts a pointer to any of the supported types.
Example:
var i int
var b bool
var s string
var l rencode.List
err := e.Scan(&i, &b, &s, &l)
You can also decode a dictionary directly into a struct:
var s struct {
Alpha int
Beta string
Gamma float64 `rencode:"rencode-exclude"`
}
var d Dictionary
d.Add("alpha", int(54123))
d.Add("beta", "test")
err := d.ToStruct(&s, "rencode-exclude")
In this example every field/value of the dictionary must be mapped to a struct field, except those tagged as rencode-exclude
.
This works as well with nested dictionaries mapping to nested structs.
Only the following types are supported:
The rencode.List
and rencode.Dictionary
implement Python-alike features and can store values and keys of
the simpler types enumerated above.
reflect.Value
instead of the generated codego-rencode is licensed under GNU GPL v2, see COPYING for license information.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.