Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Deserialize ¶
Deserialize `data` according to the schema of `s`, and store the value into it. `s` must be a pointer type variable that points to the original schema of `data`.
Example ¶
a := A{B: 123} data, _ := borsh.Serialize(a) b := &A{} err := borsh.Deserialize(b, data) if err != nil { log.Fatal(err) }
Output:
func Serialize ¶
Serialize `s` into bytes according to Borsh's specification(https://borsh.io/).
The type mapping can be found at https://github.com/hmn-fnd/borsh-go.
Example ¶
a := A{B: 123} data, err := borsh.Serialize(a) if err != nil { log.Fatal(err) } log.Print(data)
Output:
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
func NewDecoder ¶
Example ¶
a := A{B: 123} data, _ := borsh.Serialize(a) b := &A{} d := borsh.NewDecoder(bytes.NewReader(data)) if err := d.Decode(b); err != nil { log.Fatal(err) }
Output:
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
func NewEncoder ¶
Example ¶
a := A{B: 123} b := strings.Builder{} e := borsh.NewEncoder(&b) if err := e.Encode(a); err != nil { log.Fatal(err) }
Output:
Click to show internal directories.
Click to hide internal directories.