解决go/micro/proto版本冲突

656 阅读1分钟
  1. 在service包下的微服务包中,如果没有自动生成go.mod文件,使用以下命令生成go.mod
go mod init
  1. 下载所有依赖 选择一个报错的地方,点击sync...
    如果不行,尝试:
go get ./
  1. Enabling the go modules integration Preferences > GO > GO Modules

  2. 开启go modules后可能会导致web包中的import出现问题,解决方法:

    • 新建go.mod文件
    go mod init test_go_mod
    
    • 重新下载安装包(或点击sync...
    go get -u github.com/gin-gonic/gin
    
    • 更改自己的包的路径 更改前的路径为bj38web/web/utils,此时无法识别

    Screen Shot 2021-07-10 at 12.40.56 PM.png

    需要改成mod名/utils,比如test_go_mod/utils Screen Shot 2021-07-10 at 12.42.34 PM.png