1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
package imported
import (
"encoding/json"
"github.com/gogo/protobuf/proto"
)
type B struct {
A
}
func (b B) Equal(other B) bool {
return b.A.Equal(other.A)
}
func (b B) Size() int {
return b.A.Size()
}
func NewPopulatedB(r randyA) *B {
a := NewPopulatedA(r, false)
if a == nil {
return nil
}
return &B{*a}
}
func (b B) Marshal() ([]byte, error) {
return proto.Marshal(&b.A)
}
func (b *B) Unmarshal(data []byte) error {
a := &A{}
err := proto.Unmarshal(data, a)
if err != nil {
return err
}
b.A = *a
return nil
}
func (b B) MarshalJSON() ([]byte, error) {
return json.Marshal(b.A)
}
func (b *B) UnmarshalJSON(data []byte) error {
a := &A{}
err := json.Unmarshal(data, a)
if err != nil {
return err
}
*b = B{A: *a}
return nil
}
|