1 Star 1 Fork 0

Golang语言社区 / protobuf

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
b.go 764 Bytes
一键复制 编辑 原始数据 按行查看 历史
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, true)
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
}
1
https://gitee.com/wwwgolangltd/protobuf.git
git@gitee.com:wwwgolangltd/protobuf.git
wwwgolangltd
protobuf
protobuf
baf2ea5cdb7c

搜索帮助

53164aa7 5694891 3bd8fe86 5694891