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 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看