plugin "github.com/golang/protobuf/protoc-gen-go/plugin" ) // 情報 受 取 何 処理 出力 内容 作成 func process(req *plugin.CodeGeneratorRequest) *plugin.CodeGeneratorResponse { files := make(map[string]*descriptor.FileDescriptorProto) for _, f := range req.ProtoFile { files[f.GetName()] = f // 読 取 .proto } var res plugin.CodeGeneratorResponse for _, fname := range req.FileToGenerate { f := files[fname] for _, service := range f.GetService() { content := makeContent(service.GetName(), service.GetMethod()) // 出力 内容 res.File = append(res.File, &plugin.CodeGeneratorResponse_File{ // 出力 内容 入 Name: proto.String("friends.txt"), Content: proto.String(content), }) } } return &res } // 生成 内容 作 func makeContent(serviceName string, methods []*descriptor.MethodDescriptorProto) string { var content string for _, m := range methods { methodName := m.GetName() content += fmt.Sprintf(" %s %s 得意 \n", serviceName, methodName) } return content }