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 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题