Created
April 17, 2018 01:32
-
-
Save jasonkeene/1e153e4c4c387db44891150c72c5ea58 to your computer and use it in GitHub Desktop.
An Exercise in dumping the file descriptor of the grpc-go helloworld example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"compress/gzip" | |
"io/ioutil" | |
"log" | |
"github.com/davecgh/go-spew/spew" | |
"github.com/golang/protobuf/proto" | |
_ "google.golang.org/grpc/examples/helloworld/helloworld" | |
"github.com/golang/protobuf/protoc-gen-go/descriptor" | |
) | |
func main() { | |
c := proto.FileDescriptor("helloworld.proto") | |
r, err := gzip.NewReader(bytes.NewReader(c)) | |
if err != nil { | |
log.Fatal(err) | |
} | |
u, err := ioutil.ReadAll(r) | |
if err != nil { | |
log.Fatal(err) | |
} | |
var d descriptor.FileDescriptorProto | |
err = proto.Unmarshal(u, &d) | |
if err != nil { | |
log.Fatal(err) | |
} | |
spew.Dump(d) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment