package proto
import (
"encoding/json"
"errors"
"fmt"
"strconv"
protoV2 "google.golang.org/protobuf/proto"
)
var (
ErrNil = errors .New ("proto: Marshal called with nil" )
ErrTooLarge = errors .New ("proto: message encodes to over 2 GB" )
ErrInternalBadWireType = errors .New ("proto: internal error: bad wiretype for oneof" )
)
type Stats struct { Emalloc, Dmalloc, Encode, Decode, Chit, Cmiss, Size uint64 }
func GetStats () Stats { return Stats {} }
func MarshalMessageSet (interface {}) ([]byte , error ) {
return nil , errors .New ("proto: not implemented" )
}
func UnmarshalMessageSet ([]byte , interface {}) error {
return errors .New ("proto: not implemented" )
}
func MarshalMessageSetJSON (interface {}) ([]byte , error ) {
return nil , errors .New ("proto: not implemented" )
}
func UnmarshalMessageSetJSON ([]byte , interface {}) error {
return errors .New ("proto: not implemented" )
}
func RegisterMessageSetType (Message , int32 , string ) {}
func EnumName (m map [int32 ]string , v int32 ) string {
s , ok := m [v ]
if ok {
return s
}
return strconv .Itoa (int (v ))
}
func UnmarshalJSONEnum (m map [string ]int32 , data []byte , enumName string ) (int32 , error ) {
if data [0 ] == '"' {
var repr string
if err := json .Unmarshal (data , &repr ); err != nil {
return -1 , err
}
val , ok := m [repr ]
if !ok {
return 0 , fmt .Errorf ("unrecognized enum %s value %q" , enumName , repr )
}
return val , nil
}
var val int32
if err := json .Unmarshal (data , &val ); err != nil {
return 0 , fmt .Errorf ("cannot unmarshal %#q into enum %s" , data , enumName )
}
return val , nil
}
type InternalMessageInfo struct {}
func (*InternalMessageInfo ) DiscardUnknown (m Message ) {
DiscardUnknown (m )
}
func (*InternalMessageInfo ) Marshal (b []byte , m Message , deterministic bool ) ([]byte , error ) {
return protoV2 .MarshalOptions {Deterministic : deterministic }.MarshalAppend (b , MessageV2 (m ))
}
func (*InternalMessageInfo ) Merge (dst , src Message ) {
protoV2 .Merge (MessageV2 (dst ), MessageV2 (src ))
}
func (*InternalMessageInfo ) Size (m Message ) int {
return protoV2 .Size (MessageV2 (m ))
}
func (*InternalMessageInfo ) Unmarshal (m Message , b []byte ) error {
return protoV2 .UnmarshalOptions {Merge : true }.Unmarshal (b , MessageV2 (m ))
}
The pages are generated with Golds v0.8.2 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .