All Projects → tallstoat → Pbparser

tallstoat / Pbparser

Licence: mit
Golang library for parsing protocol buffer (.proto) files

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Pbparser

Proto
parser for Google ProtocolBuffers definition
Stars: ✭ 359 (+1096.67%)
Mutual labels:  protobuf, parser
Pq
a command-line Protobuf parser with Kafka support and JSON output
Stars: ✭ 120 (+300%)
Mutual labels:  protobuf, parser
Slang
A small, flexible and extensible front-end for GLSL.
Stars: ✭ 10 (-66.67%)
Mutual labels:  parser
X509
A PHP library for X.509 public key certificates, attribute certificates, certification requests and certification path validation.
Stars: ✭ 27 (-10%)
Mutual labels:  parser
D Prolog
A Prolog implementation in D language
Stars: ✭ 20 (-33.33%)
Mutual labels:  parser
Purepos
PurePos is an open source hybrid morphological tagger.
Stars: ✭ 12 (-60%)
Mutual labels:  parser
Tensorflow Java Client
Example of Java/Scala grpc client for tensorflow_serving (https://github.com/tensorflow/serving)
Stars: ✭ 20 (-33.33%)
Mutual labels:  protobuf
Grpc
An Elixir implementation of gRPC
Stars: ✭ 858 (+2760%)
Mutual labels:  protobuf
Mysqllog
Lightweight MySQL slow query log parser in Go
Stars: ✭ 29 (-3.33%)
Mutual labels:  parser
Sol Profiler
CLI Tool to List & Store Solidity Smart Contract Methods Attributes
Stars: ✭ 20 (-33.33%)
Mutual labels:  parser
Lfuzzer
Fuzzing Parsers with Tokens
Stars: ✭ 28 (-6.67%)
Mutual labels:  parser
Onion Crawler
Tor website crawler (specific for Alphabay at the time)
Stars: ✭ 15 (-50%)
Mutual labels:  parser
Xml Js
Converter utility between XML text and Javascript object / JSON text.
Stars: ✭ 874 (+2813.33%)
Mutual labels:  parser
Go Deb Version
A golang library for parsing deb package versions
Stars: ✭ 21 (-30%)
Mutual labels:  parser
Pgoapi
Unofficial PokemonGO API in Python
Stars: ✭ 874 (+2813.33%)
Mutual labels:  protobuf
Errorstacks
Tiny library to parse error stack traces
Stars: ✭ 29 (-3.33%)
Mutual labels:  parser
Itunes smartplaylist
iTunes Smart playlist parser with Python. Convert to Kodi xsp smart playlists.
Stars: ✭ 10 (-66.67%)
Mutual labels:  parser
Scalameta
Library to read, analyze, transform and generate Scala programs
Stars: ✭ 879 (+2830%)
Mutual labels:  parser
Algebra Latex
Parse and calculate latex formatted math
Stars: ✭ 20 (-33.33%)
Mutual labels:  parser
Ssp
C++ CSV parser
Stars: ✭ 30 (+0%)
Mutual labels:  parser

Build Status GoReportCard GoDoc

pbparser

Pbparser is a library for parsing protocol buffer (".proto") files.

Why?

Protocol buffers are a flexible and efficient mechanism for serializing structured data. The Protbuf compiler (protoc) is the source of truth when it comes to parsing proto files. However protoc can be challenging to use in some scenarios :-

  • Protoc can be invoked by spawning a process from go code. If the caller now relies on the output of the compiler, they would have to parse the messages on stdout. This is fine for situations which need mere validations of proto files but does not work for usecases which require a standard defined parsed output structure to work with.
  • Protoc can also be invoked with --descriptor_set_out option to write out the proto file as a FileDescriptorSet (a protocol buffer defined in descriptor.proto). Ideally, this should have been sufficient. However, this again requires one to write a text parser to parse it.

This parser library is meant to address the above mentioned challenges.

Installing

Using pbparser is easy. First, use go get to install the latest version of the library.

go get -u github.com/tallstoat/pbparser

Next, include pbparser in your application code.

import "github.com/tallstoat/pbparser"

APIs

This library exposes two apis. Both the apis return a ProtoFile datastructure and a non-nil Error if there is an issue in the parse operation itself or the subsequent validations.

func Parse(r io.Reader, p ImportModuleProvider) (ProtoFile, error)

The Parse() function expects the client code to provide a reader for the protobuf content and also a ImportModuleProvider which can be used to callback the client code for any imports in the protobuf content. If there are no imports, the client can choose to pass this as nil.

func ParseFile(file string) (ProtoFile, error)

The ParseFile() function is a utility function which expects the client code to provide only the path of the protobuf file. If there are any imports in the protobuf file, the parser will look for them in the same directory where the protobuf file resides.

Choosing an API

Clients should use the Parse() function if they are not comfortable with letting the pbparser library access the disk directly. This function should also be preferred if the imports in the protobuf file are accessible to the client code but the client code does not want to give pbparser direct access to them. In such cases, the client code has to construct a ImportModuleProvider instance and pass it to the library. This instance must know how to resolve a given "import" and provide a reader for it.

On the other hand, Clients should use the ParseFile() function if all the imported files as well as the protobuf file are on disk relative to the directory in which the protobuf file resides and they are comfortable with letting the pbparser library access the disk directly.

Usage

Please refer to the examples for API usage.

Issues

If you run into any issues or have enhancement suggestions, please create an issue here.

However I would much prefer PRs since at this time I'm unable to work on issues :-/

Contributing

  1. Fork this repo.
  2. Create your feature branch (git checkout -b my-new-feature).
  3. Commit your changes (git commit -am 'Add some feature').
  4. Push to the branch (git push origin my-new-feature).
  5. Create new Pull Request.

License

Pbparser is released under the MIT license. See LICENSE

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].