proxy.golang.org : github.com/odeke-em/go-wire
go-wire is our custom codec package for serializing and deserializing data and structures as binary and JSON blobs. In order to get started with go-wire we need to: 1) Choose the receiving structure for deserializing. It MUST be an interface{} and during registration it MUST be wrapped as a struct for example 2) Decide the IDs for the respective types that we'll be dealing with. We shall call these the concrete types. 3) Register the receiving structure as well as each of the concrete types. Typically do this in the init function so that it gets run before other functions are invoked Encoding to binary is performed by invoking wire.WriteBinary. You'll need to provide the data to be encoded/serialized as well as where to store it and storage for the number of bytes written as well as any error encountered Decoding from binary is performed by invoking wire.ReadBinary. The data being decoded has to be retrieved from the decoding receiver that we previously defined i.e. Receiver for example Note that in the decoding example we used to receive the value. That correlates with the type that we registered in wire.RegisterInterface
Registry
-
Source
- Documentation
- JSON
purl: pkg:golang/github.com/odeke-em/go-wire
License: Apache-2.0
Latest release: over 7 years ago
First release: about 8 years ago
Namespace: github.com/odeke-em
Stars: 0 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 27 days ago