duanfei8399 2015-06-08 19:50
浏览 29
已采纳

Go +协议缓冲区的行为真的很奇怪

I'm writing a service-based server for a project I'm working on, which is written in Go and uses Protocol Buffers for inter-service communication. Everything was working fine until I added protocols named DeviceRequest and DeviceResponse, now the compiler can't find them, while the go source of the protocol exists and is set up in my GOPATH. WebStorm also finds them, but for some reason the compiler doesn't. The strange thing is that old protocols of which the Go source doesn't exist anymore do work (Webstorm also does not recognize them), see these screenshots enter image description hereenter image description hereenter image description here

I've tried deleting the files in my GOPATH, but that didn't work. My guess is that go is using some kind of cache memory but I couldn't find anything about that online.

  • 写回答

1条回答 默认 最新

  • dream5694 2015-06-08 20:27
    关注

    Protocol buffers are not compiled automatically into Go code unless you have a third party tool that does this. The protoc tool that is part of Protocol Buffers would be used to create the Go implementation of the .proto files. The output should reside in your $GOPATH/src. The .a files would be stored under $GOPATH/pkg. The code completion looks at the $GOPATH/pkg whereas the "go" tool would look in $GOPATH/src for anything that had changed.

    Remove the contents of $GOPATH/pkg and then run "go install" to recreate the .a files.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ansys fluent计算闪退
  • ¥15 有关wireshark抓包的问题
  • ¥15 需要写计算过程,不要写代码,求解答,数据都在图上
  • ¥15 向数据表用newid方式插入GUID问题
  • ¥15 multisim电路设计
  • ¥20 用keil,写代码解决两个问题,用库函数
  • ¥50 ID中开关量采样信号通道、以及程序流程的设计
  • ¥15 U-Mamba/nnunetv2固定随机数种子
  • ¥15 vba使用jmail发送邮件正文里面怎么加图片
  • ¥15 vb6.0如何向数据库中添加自动生成的字段数据。