summaryrefslogtreecommitdiff
path: root/go
diff options
context:
space:
mode:
authorRonak Jain <ronakjain@outlook.in>2016-12-06 02:50:38 +0530
committerWouter van Oortmerssen <wvo@google.com>2016-12-05 13:20:38 -0800
commita31ddd2bb38f719996137c9c35bc702f2abaefa5 (patch)
tree697dbbe0095b62d58b506e424c6a7a3e7946a49f /go
parentbc2ec7119bd95230c4eb9a730a5439472efe01fa (diff)
downloadflatbuffers-a31ddd2bb38f719996137c9c35bc702f2abaefa5.tar.gz
flatbuffers-a31ddd2bb38f719996137c9c35bc702f2abaefa5.tar.bz2
flatbuffers-a31ddd2bb38f719996137c9c35bc702f2abaefa5.zip
Support for Golang GRPC (Experimental) (#4082)
* support for grpc golang * refactored grpc go generator * added grpc-go test and refactored * refactored idl_gen_grpc.cpp * fixed grpc generate method name * refactored flatc and fixed line length issue * added codec to go lib and fixed formatting issues * fixed spacing issues
Diffstat (limited to 'go')
-rw-r--r--go/grpc.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/go/grpc.go b/go/grpc.go
new file mode 100644
index 00000000..07d374b1
--- /dev/null
+++ b/go/grpc.go
@@ -0,0 +1,23 @@
+package flatbuffers
+
+// FlatbuffersCodec implements gRPC-go Codec which is used to encode and decode messages.
+var Codec string = "flatbuffers"
+
+type FlatbuffersCodec struct{}
+
+func (FlatbuffersCodec) Marshal(v interface{}) ([]byte, error) {
+ return v.(*Builder).FinishedBytes(), nil
+}
+
+func (FlatbuffersCodec) Unmarshal(data []byte, v interface{}) error {
+ v.(flatbuffersInit).Init(data, GetUOffsetT(data))
+ return nil
+}
+
+func (FlatbuffersCodec) String() string {
+ return Codec
+}
+
+type flatbuffersInit interface {
+ Init(data []byte, i UOffsetT)
+}