package
module
Version:
v1.2.0
Opens a new window with list of versions in this module.
Published: Jul 7, 2021
License: Apache-2.0
Opens a new window with license information.
Imports: 3
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
Go Protobuf
A go protobuf library, used to help parse data from protobuf or parse to protobuf.
Usage
package main
import (
"fmt"
"github.com/x-punch/go-protobuf"
pb "google.golang.org/protobuf/types/known/structpb"
)
func main() {
req, err := protobuf.MarshalValue(666)
if err != nil {
panic(err)
}
fmt.Println(req)
resp := &pb.Value{Kind: &pb.Value_NumberValue{NumberValue: 666}}
v := protobuf.UnmarshalValue(resp)
fmt.Println(v)
}
Documentation
¶
MarshalValue convert generic type into protobuf value type
Only support NullValue, NumberValue, BoolValue, StringValue
func UnmarshalValue(v *pb.Value) interface{}
UnmarshalValue convert protobuf value type into generic value type
Source Files
¶
Click to show internal directories.
Click to hide internal directories.