You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GoLang gRPC项目引入protoc-gen-openapiv2依赖报错求助

GoLang+gRPC项目中安装proto依赖时遇到的问题

我在基于GoLang+gRPC的技术栈中给proto文件添加分页功能,引入了以下依赖:

import "google/api/annotations.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
import "google/protobuf/timestamp.proto";

尝试通过go install或go get安装这些依赖时,分别出现如下报错:

使用go install时的报错

go install protoc-gen-openapiv2/options/annotations.proto@latest                                                        
go: protoc-gen-openapiv2/options/annotations.proto@latest: malformed module path "protoc-gen-openapiv2/options/annotations.proto": missing dot in first path element

使用go get时的报错

go get protoc-gen-openapiv2/options/annotations.proto                                                                 
go: go.mod file not found in current directory or any parent directory.
        'go get' is no longer supported outside a module.

我已经查阅过grpc-gateway的官方文档,确认操作流程无误,但仍遇到该问题。想问问有没有其他人遇到过类似的情况?

我的相关proto消息定义如下:

message BlogAllRequest {
    option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = {
        json_schema: {
            required: ["filter"]
        }
    };

    string id = 1;
    int32 page = 2;
    int32 per_page = 3 [json_name="per_page"];
    SortOrder order = 4 [json_name = "order"];

}

内容的提问来源于stack exchange,提问作者Mike3355

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.30 15:03:27