/fproto

Parse protobuf files into Go structs

Primary LanguageGo

fproto

GoDoc

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

See elements.go to see the structs definitions.

Uses https://github.com/emicklei/proto for parsing.

The subpackage "fdep" uses this to build relationships between proto files and extracting types, helping creating source code generators.

install

go get -u -v github.com/RangelReale/fproto

usage

package main

import (
    "fmt"
    "os"

    "github.com/RangelReale/fproto"
)

func main() {
    file, err := os.Open("/file/name")
    if err != nil {
        return nil, err
    }
    defer file.Close()

    protofile, err := fproto.Parse(file)
    if err != nil {
        return nil, err
    }
    
    fmt.Printf("Package name: %s\n", protofile.PackageName)
}

related

author

Rangel Reale (rangelspam@gmail.com)