jozn / proto

parser for Google ProtocolBuffers definition

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

proto

Build Status Go Report Card GoDoc

Package in Go for parsing Google Protocol Buffers [.proto files version 2 + 3] (https://developers.google.com/protocol-buffers/docs/reference/proto3-spec)

This repository also includes 2 commands. The protofmt tool is for formatting .proto files and the proto2xsd tool is for generating XSD files from .proto version 3 files.

usage as package

package main

import (
	"os"

	"github.com/emicklei/proto"
)

func main() {
	reader, _ := os.Open("test.proto")
	defer reader.Close()
	parser := proto.NewParser(reader)
	definition, _ := parser.Parse()
	formatter := proto.NewFormatter(os.Stdout, " ")
	formatter.Format(definition)
}

usage of proto2xsd command

> proto2xsd -help
	Usage of proto2xsd [flags] [path ...]
	-ns string
		namespace of the target types (default "http://your.company.com/domain/version")		
	-w	write result to an XSD files instead of stdout

See folder cmd/proto2xsd/README.md for more details.

usage of protofmt command

> protofmt -help
	Usage of protofmt [flags] [path ...]
	-w	write result to (source) files instead of stdout

See folder cmd/protofmt/README.md for more details.

how to install

go get -u -v github.com/emicklei/proto

© 2017, ernestmicklei.com. MIT License. Contributions welcome.

About

parser for Google ProtocolBuffers definition

License:MIT License


Languages

Language:Go 56.1%Language:Protocol Buffer 43.8%Language:Shell 0.1%