1
0
mirror of https://github.com/go-kratos/kratos.git synced 2026-05-22 10:15:24 +02:00
This commit is contained in:
chenzhihui
2021-02-17 17:14:47 +08:00
parent 3daca16dc5
commit 3566386a89
763 changed files with 7530 additions and 77187 deletions
+30
View File
@@ -0,0 +1,30 @@
// Package proto defines the protobuf codec. Importing this package will
// register the codec.
package proto
import (
"google.golang.org/grpc/encoding"
"google.golang.org/protobuf/proto"
)
// Name is the name registered for the proto compressor.
const Name = "proto"
func init() {
encoding.RegisterCodec(codec{})
}
// codec is a Codec implementation with protobuf. It is the default codec for Transport.
type codec struct{}
func (codec) Marshal(v interface{}) ([]byte, error) {
return proto.Marshal(v.(proto.Message))
}
func (codec) Unmarshal(data []byte, v interface{}) error {
return proto.Unmarshal(data, v.(proto.Message))
}
func (codec) Name() string {
return Name
}