Write the Code. Change the World.

12月 08

goframe 框架中,引入其他 proto 文件时会报错 Import "xxx.proto" was not found or had errors.

比如在 manifest/protobuf 下,有 base.protogame.proto 文件,如果在 game.proto 文件中引入 base.proto,vscode会报错 Import "base.proto" was not found or had errors.

处理

在项目根目录下创建 .vscode 目录,在该目录下新建 settings.json。添加以下配置就好。

{
  "protoc": {
    // 指定 protoc 编译器的路径(可选,但更准确)
    // "path": "D:\\ProgramData\\anaconda3\\Library\\bin\\protoc.exe",
    // 关键:指定导入文件的搜索路径,与 gf gen pb 保持一致
    "compile_on_save": false,
    "options": [
      "--proto_path=${workspaceFolder}/manifest/protobuf"
    ]
  }
}