Debugging Go Inside Docker, Using Visual Studio Code and Remote Containers

Debugging Go Inside Docker, Using Visual Studio Code and Remote Containers

In this post, we’ll write a very simple Go application that will utilize Exiftool to pull and display metadata from a PDF. Using the Remote Containers extension, we’ll install Exiftool only in our Docker container, and debug the application inside the container. Debugging Go Inside Docker, Using Visual Studio Code and Remote Containers

There have been many times in my career or when working on personal projects, that I have needed some open-source executables to help me complete my task. I have used things like  Weasyprint,  WKHTMLTOPDF,  Exiftool,  Ghostscript, the list goes on and on (these are just some of the more recent ones). These are all fantastic tools, and I’m sure there are hundreds more out there. They have saved me countless hours of work by providing amazing functionality that I either don’t have to write or just don’t know where I would even begin if I had to! I am thankful for these tools and the many more that are free and open-source.

However, I do not want to install them on my local machine. I am 100% against installing extra software on my personal machine that is needed for a project, not in pursuit of helping me on a daily basis. If you happen to work for a company that locks down their machines, it may be impossible to install this software locally. Thankfully, we have Docker and all its gloriousness to help us. Utilizing Docker, I can install all this software easily and use it without abandon. Even if my machine is locked down, Docker can come to the rescue.

I have used Docker so many times in these scenarios and it's been great. However, the debugging experience in this situation is not great. Since I don’t have this software installed locally, to truly see if my code is working properly I need to run it in a Docker container. This isn’t horrible, but it tends to lead to a lot of log statements and extra time consumed needlessly. Fortunately, Microsoft has an amazing extension for Visual Studio Code called  Remote Containers. From their page:

The Visual Studio Code Remote — Containers extension lets you use a Docker container as a full-featured development environment. It allows you to open any folder inside (or mounted into) a container and take advantage of Visual Studio Code’s full feature set. A devcontainer.json file in your project tells VS Code how to access (or create) a development container with a well-defined tool and runtime stack. This container can be used to run an application or to sandbox tools, libraries, or runtimes needed for working with a codebase.

In this post, we’ll write a very simple Go application that will utilize Exiftool to pull and display metadata from a PDF. Using the Remote Containers extension, we’ll install Exiftool only in our Docker container, and debug the application inside the container. Let’s get going!

The Setup

The application is quite simple, all it does is run Exiftool against a PDF that is stored on the container. The goal of this post is to explore using the Remote Container extension, so nothing too complex is needed. Here is our code:

golang docker visual-studio-code debugging

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

COMO USAR e trabalhar com Code Review no Visual Studio Code

💲 Live CollabPlay: https://youtu.be/B6LCFSPdsE0 💲 Hospedagem com Desconto Exclusivo: https://tekers.tech/4e587 Não é todo programador que gosta de compartilh...

User Snippets (Code Shortcuts) in Visual Studio Code

#vscode Hello, my friends and fellow developers, this video is all about User Snippets. That means the Snippets (Code Shortcuts) that you can make for yourse...

How Do I Debug Async Code in Visual Studio?

Debugging async code is challenging. Let's explore some Visual Studio tools that can help you debug your async programs easier!

Python в Visual Studio Code

We are pleased to announce that the July release of the Python extension is now available for Visual Studio Code. You can download the Python extension from the Marketplace, or install it directly from the extension gallery in Visual Studio Code. If you already have the Python extension installed, you can also get the latest update by restarting Visual Studio Code. You can read more about Python support in Visual Studio Code in the documentation .

C++ Development with Visual Studio Code

If you’re looking for a fast and lightweight open-source code editor, Visual Studio Code has you covered. Come for a deep dive into the features of Visual Studio Code which provide a rich, productive environment for C++ development.