mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
added vendors
This commit is contained in:
73
vendor/github.com/gogo/protobuf/test/t.go
generated
vendored
Normal file
73
vendor/github.com/gogo/protobuf/test/t.go
generated
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
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) 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)
|
||||
}
|
Reference in New Issue
Block a user