How to use Docker to compile and run Go code from GoLand |

How to use Docker to compile and run Go code from GoLand |

Table of Contents

[…]

We call this feature “Run targets”, and it doesn’t extend to Docker support only. We currently support Docker, WSL 2, and SSH remotes.

[…]

In this article, I’ll focus on the Docker side of this feature.

[…]

Here is where the IDE steps in and can automate everything using a Docker container via the Run Targets feature.

[…]

Head over to Run | Manage Targets... | + | Docker and select the Docker type from the list.

[…]

The IDE will compile our binary on the local machine and run it via the Docker container.

[…]

That’s it! Rerunning this configuration now works against our Docker container.

[…]

This is where the Build option from the Docker target type comes in.

You’ll need to provide a Dockerfile that contains a Go installation.Below, you can find an example of such a Dockerfile.

[…]