protobuf

package module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalValue added in v1.0.1

func MarshalValue(input interface{}) (*pb.Value, error)

MarshalValue convert generic type into protobuf value type Only support NullValue, NumberValue, BoolValue, StringValue

func UnmarshalValue added in v1.0.1

func UnmarshalValue(v *pb.Value) interface{}

UnmarshalValue convert protobuf value type into generic value type

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL