Source File
proto.go
Belonging Package
google.golang.org/grpc/encoding/proto
/*
*
* Copyright 2018 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
// Package proto defines the protobuf codec. Importing this package will
// register the codec.
package proto
import (
)
// Name is the name registered for the proto compressor.
const Name = "proto"
func () {
encoding.RegisterCodec(codec{})
}
// codec is a Codec implementation with protobuf. It is the default codec for gRPC.
type codec struct{}
func (codec) ( interface{}) ([]byte, error) {
, := .(proto.Message)
if ! {
return nil, fmt.Errorf("failed to marshal, message is %T, want proto.Message", )
}
return proto.Marshal()
}
func (codec) ( []byte, interface{}) error {
, := .(proto.Message)
if ! {
return fmt.Errorf("failed to unmarshal, message is %T, want proto.Message", )
}
return proto.Unmarshal(, )
}
func (codec) () string {
return Name
}
The pages are generated with Golds v0.4.9. (GOOS=linux GOARCH=amd64)