Closed aobcvr closed 2 years ago
It seems not possible in Goland to configure a remote binary or one within a docker container.
That means the only way to use dockerized go, would be to create a directory that contains the files and binaries that the IDE expects. Those binaries should call dockerized go
instead of go
. For the binary part, this may be possible on Linux by creating executable shellscripts:
$GOROOT/bin/go
#!/bin/bash
dockerized go "$@"
$GOROOT/bin/gofmt
#!/bin/bash
dockerized gofmt "$@"
Note that gofmt is not currently included in dockerized, but we can add that.
However, the IDE will probably also need other files, such as $GOROOT/VERSION
and the pkg
directory. The go command currently installs the packages on a docker volume which is not exposed to the host, making it inaccessible to the IDE. This would need to be changed as well. Possible in theory at least.
Other files that might be needed could be extracted from the dockerized image and copied onto the host, for example in a init
script, which copies the files on the first execution. See implementation of gh.
Some higher level thoughts on this:
Dockerized proxies in/output to containerized binaries, and it auto-mounts the current dir. The binaries' environment is kept inside the container, and not exposed.
What you need in this case is not just access to a binary, but access to an environment. Of course after adding go, I also tried running goland on dockerized go, so I agree it would be great to be able to do that. The question is whether to extend the scope of dockerized from just providing binaries into providing environments on the host system.
Go could be a good use-case to try it out.
This could eventually all be wrapped into a single --install
command, e.g. dockerized --install go:1.16 ~/go
which will extract all necessary files, and generates wrapped binaries.
How to use dockerized Go when I need to specify $GOROOT and $GOPATH for linting in my IDE
https://github.com/fatih/vim-go/blob/421563081bddaec1f7a66710b5c8ee305724d2a9/doc/vim-go.txt#L123-L126 https://www.jetbrains.com/help/go/configuring-goroot-and-gopath.html