Skip to content

Protocol Buffer interoperability between go and JavaScript (using closure-library's goog.proto2)

License

Notifications You must be signed in to change notification settings

sashka/protoclosure

Repository files navigation

protoclosure

Protocol Buffer interoperability between Go's goprotobuf and JavaScript (using closure-library's goog.proto2).

JS Usage

Go Usage

PBLite format

Example message:

message Person {
  optional int32 id = 1;
  optional string name = 2;
  optional string email = 3;
}

Example encoding:

[null,1,null,"user@example.com"]

Example encoding (zero-index):

[1,null,"user@example.com"]

PBObject format

Example message:

message Person {
  optional int32 id = 1;
  optional string name = 2;
  optional string email = 3;
}

Example encoding (tag name):

{"id":1,"email":"user@example.com"}

Example encoding (tag number):

{"1":1,"3":"user@example.com"}

protoclosure development

$ # setup environment (GOPATH, etc)
$ go get gopkg.in/samegoal/protoclosure.v0
$ cd gopkg.in/samegoal/protoclosure.v0
$ # modify the source
$ go test -race
$ make  # run vet/fmt/lint, prior to sending Pull Request

To regenerate unit test protobuf files:

protoc --go_out=. gopkg.in/samegoal/protoclosure.v0/test.proto
protoc --go_out=. gopkg.in/samegoal/protoclosure.v0/package_test.proto

mv gopkg.in/samegoal/protoclosure.v0/test.pb.go gopkg.in/samegoal/protoclosure.v0/test.pb/
mv gopkg.in/samegoal/protoclosure.v0/package_test.pb.go gopkg.in/samegoal/protoclosure.v0/package_test.pb/

goprotobuf limitations:

About

Protocol Buffer interoperability between go and JavaScript (using closure-library's goog.proto2)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published