Slide 34
Slide 34 text
εΩʔϚͷϩʔυ
1 func runProtoc(args []string) ([]byte, error) {
2 buf, errBuf := new(bytes.Buffer), new(bytes.Buffer)
3
4 // with "--descriptor_set_out=/dev/stdout"
5 cmd := exec.Command("protoc", args...)
6 cmd.Stdout = buf
7 cmd.Stderr = errBuf
8 if err := cmd.Run(); err != nil {
9 if errBuf.Len() != 0 {
10 return nil, errors.New(errBuf.String())
11 }
12 return nil, err
13 }
14 return buf.Bytes(), nil
15 }