Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

go.uber.org/protoidl

Package Overview
Dependencies
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

go.uber.org/protoidl

Go Modules
Version
v1.1.0
Version published
Created
Source

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 3 commands. The protofmt tool is for formatting .proto files. The proto2xsd tool is for generating XSD files from .proto version 3 files. The proto2gql tool is for generating the GraphQL Schema.

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 proto2gql command

> proto2gql -help
    Usage of proto2gql [flags] [path ...]

    -std_out
        Writes transformed files to stdout
    -txt_out string
        Writes transformed files to .graphql file
    -go_out string
        Writes transformed files to .go file
    -js_out string
        Writes transformed files to .js file
    -package_alias value
        Renames packages using given aliases
    -resolve_import value
        Resolves given external packages
    -no_prefix
        Disables package prefix for type names

See folder cmd/proto2gql/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

known issues

  • the proto2 test file in protofmt folder contains character escape sequences that are currently not accepted by the scanner. See line 537 and 573.

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

FAQs

Package last updated on 30 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts