dongmeng1868 2017-03-26 08:02
浏览 1722

gogo.proto:找不到文件

protoc --gogofaster_out=. image.proto

I get this error message

/home/abc/src/github.com/gogo/protobuf/gogoproto/gogo.proto: File not found.

image.proto: Import "/home/abc/src/github.com/gogo/protobuf/gogoproto/gogo.proto" was not found or had errors.

The file is definitely there. I can reach it from the reported path in the error.

My proto file looks like this:

package image;

import "/home/abc/src/github.com/gogo/protobuf/gogoproto/gogo.proto";

message Frame {
required bool fragment = 1; 
required int32  fragmentID = 2; 
required bool lastFragment = 3; 
required bytes data = 4;
}

I have a Makefile in the dir where the proto file is. Looks like this:

regenerate:
--proto_path=../../github.com/gogo/protobuf/gogoproto:../../github.com/gogo/protobuf/protobuf/google/protobuf:. --gogofaster_out=. *.proto

What can I do to resolve the path error?

  • 写回答

1条回答 默认 最新

  • doulu1867 2017-03-26 09:08
    关注

    As in this issue, you could try and import only the relative path:

    import "github.com/gogo/protobuf/gogoproto/gogo.proto";
    

    Make sure that GOPATH is set to /home/abc first.

    I mention protobuf PR 241, where the makefile defines the PATH to use:

    regenerate: 
      protoc-min-version --version="3.0.0" 
        --proto_path=$(GOPATH)/src/image:
                     $(GOPATH)/src/github.com/go‌​go/protobuf/protobuf‌​:
                     $(GOPATH)/src/githu‌​b.com/gogo/protobuf/‌​protobuf/google/prot‌​obuf:
                     . --gogo_out=. *.proto 
    

    The OP mention this thread, which points out:

    The dependencies call other dependencies in "google/protobuf/", so these need to be in the path correctly also.
    The errors are pretty misleading

    Also when using gogoproto extensions you should use gogofast_out.
    gofast_out is only for when you are not using any extensions, but want some extra speed.
    gogofast_out / gofast_out has no side effects.
    gogofaster_out makes most fields nullable=false.

    评论

报告相同问题?

悬赏问题

  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题