2017-07-23 15:56
浏览 583

如何从Docker容器配置go sdk和GOPATH?

I'm trying to configure golang project with Jetbrains Gogland and docker compose. I want to use GOPATH and go from the docker container. I mean using the go installation from the container for the autocomplete etc without installing golang on the local machine. the project structure is:

project root
         some other packages
         all the front files...

After that, I want to deploy my back folder to the /go/src/app in the docker container. The problem is that when I develop the project I can''t use autocomplete as this project is not in my local GOPATH and there are different golang versions in the docker container and on my local machine I already read this question but I still can't solve my issue.

图片转代码服务由CSDN问答提供 功能建议

我正在尝试使用Jetbrains Gogland和docker compose配置golang项目。 我想使用GOPATH并从docker容器中转到。 我的意思是从容器中使用go安装进行自动完成等操作,而无需在本地计算机上安装golang。 项目结构为:

 back | 
 front | 

之后, 我想将我的 back 文件夹部署到Docker容器中的 / go / src / app 。 问题在于,当我开发项目时,我无法使用自动完成功能,因为该项目不在我的本地GOPATH中,并且docker容器和本地计算机上有不同的golang版本 我已经阅读这个问题,但我仍然无法解决我的问题。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dtn51137 2017-07-23 23:25

    At the moment this is not possible. Nor do I see how it could be possible in the future. Mounting a volume in docker means you "hide" the contents of that folder from the container and use the files on the host instead. As such, any time you'll mount the directory from your machine, your container files from that instance won't be available to the machine. This means you can't have Go installed in the container and then mount a folder and use that location for the Go sources. If you are thinking: I'll just mount things in another place, do some symlink magic / copy files around, that's just a bad idea that leads to nowhere.

    Gogland supports remote debugging as of EAP 10, released a a few weeks ago. This allows you to debug applications running in containers or on remote hosts. As such, you can install Go, and the source code on your machine but have them running in containers.

    解决 无用
    打赏 举报

相关推荐 更多相似问题