---
title: "3.3.协议文件"
url: "https://goframe.org/course/proxima-book/word-protocol"
markdown_url: "https://goframe.org/course/proxima-book/word-protocol.md"
locale: "zh-Hans"
version: "2.10.x(Latest)"
section: "实战教程"
category: "实战教程 / proxima-book / 第三章-单词服务"
published: "2024-12-17"
updated: "2024-12-17"
description: "介绍了单词服务的 Protocol Buffers 协议文件定义，包括创建和获取单词等接口的协议设计和实现。"
keywords: ["GoFrame", "Protocol Buffers", "gRPC", "API definition", "word service protocol", "microservices communication"]
---

# 3.3.协议文件

这里我就从简了，省略了更新，删除等操作，只写了`Create`和`Get`，用作示例。

*app/word/manifest/protobuf/words/v1/words.proto*
```go
syntax = "proto3";  
  
package words.v1;  
  
option go_package = "proxima/app/word/api/words/v1";  
  
import "pbentity/words.proto";  
  
service Words{  
  rpc Create(CreateReq) returns (CreateRes) {}  
  rpc Get(GetReq) returns (GetRes) {}  
}  
  
message CreateReq {  
  uint32 uid = 1; // v:required  
  string word = 2; // v:required  
  string definition = 3; // v:required  
}  
  
message CreateRes {  
  uint32 id = 1;  
}  
  
message GetReq {  
  uint32 id = 1; // v:required  
}  
  
message GetRes {  
  pbentity.Words words = 1;  
}
