代码拉取完成,页面将自动刷新
package test
import (
"encoding/json"
"strings"
"github.com/gogo/protobuf/proto"
)
type T struct {
Data string
}
func (gt *T) protoType() *ProtoType {
return &ProtoType{
Field2: >.Data,
}
}
func (gt T) Equal(other T) bool {
return gt.protoType().Equal(other.protoType())
}
func (gt *T) Size() int {
proto := &ProtoType{
Field2: >.Data,
}
return proto.Size()
}
func NewPopulatedT(r randyThetest) *T {
data := NewPopulatedProtoType(r, false).Field2
gt := &T{}
if data != nil {
gt.Data = *data
}
return gt
}
func (r T) Marshal() ([]byte, error) {
return proto.Marshal(r.protoType())
}
func (r *T) MarshalTo(data []byte) (n int, err error) {
return r.protoType().MarshalTo(data)
}
func (r *T) Unmarshal(data []byte) error {
pr := &ProtoType{}
err := proto.Unmarshal(data, pr)
if err != nil {
return err
}
if pr.Field2 != nil {
r.Data = *pr.Field2
}
return nil
}
func (gt T) MarshalJSON() ([]byte, error) {
return json.Marshal(gt.Data)
}
func (gt *T) UnmarshalJSON(data []byte) error {
var s string
err := json.Unmarshal(data, &s)
if err != nil {
return err
}
*gt = T{Data: s}
return nil
}
func (gt T) Compare(other T) int {
return strings.Compare(gt.Data, other.Data)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。