<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Trystan Sarrade</title>
    <description>The latest articles on DEV Community by Trystan Sarrade (@trystan_sarrade).</description>
    <link>https://dev.to/trystan_sarrade</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F284024%2Fe1b7df6a-9940-4b92-ab23-a6029ea504c6.jpg</url>
      <title>DEV Community: Trystan Sarrade</title>
      <link>https://dev.to/trystan_sarrade</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/trystan_sarrade"/>
    <language>en</language>
    <item>
      <title>Live-Reload and Debugging Go Applications Within a Docker Container</title>
      <dc:creator>Trystan Sarrade</dc:creator>
      <pubDate>Sun, 26 Jan 2025 16:22:58 +0000</pubDate>
      <link>https://dev.to/trystan_sarrade/live-reload-and-debugging-go-applications-within-a-docker-container-5d07</link>
      <guid>https://dev.to/trystan_sarrade/live-reload-and-debugging-go-applications-within-a-docker-container-5d07</guid>
      <description>&lt;p&gt;During my journey of learning Golang, I wanted to replicate my preferred development workflow: live-reloading while debugging inside a Docker container. This approach had been a cornerstone of my work with Node.js, and I aimed to achieve the same seamless experience with Go. Surprisingly, I found limited resources online addressing the integration of live-reloading and debugging within a Docker environment.&lt;/p&gt;

&lt;p&gt;To clarify, &lt;em&gt;live-reloading&lt;/em&gt; refers to the automatic termination and relaunch of a process when changes are detected in the source files. This differs from &lt;em&gt;hot-reloading&lt;/em&gt;, where parts of the memory are patched dynamically without restarting the process.&lt;/p&gt;

&lt;p&gt;Debugging, on the other hand, is an essential tool for inspecting the execution flow of a program. While it may seem daunting to beginners, once mastered, debugging proves far more efficient and effective than scattering logs throughout your codebase.&lt;/p&gt;

&lt;p&gt;Finally, working within a Docker container has become a modern and reliable method for developing applications. This approach ensures that your application runs consistently across virtual machines or PaaS platforms, eliminating risks tied to operating system or server configuration discrepancies. Combining Docker with &lt;em&gt;live-reloading&lt;/em&gt; and debugging not only streamlines the development process but also sets a robust foundation for delivering reliable software.&lt;/p&gt;

&lt;p&gt;Here’s a quick guide to help you integrate live-reloading and debugging into your development workflow for Golang within a Docker container.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Quick note: This guide is based on my setup using Windows 11 with WSL (Windows Subsystem for Linux). If you're on Linux, the steps should be identical, and for macOS users, the process is likely very similar.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you're using Windows for Go development, I highly recommend leveraging WSL. The Windows file system is significantly slower than Linux (and WSL), which means compiling your Go programs natively on Windows can take much longer. By using a WSL host, you'll notice substantial improvements in both compilation speed and overall development efficiency.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stack used
&lt;/h2&gt;

&lt;p&gt;Here’s the stack we’ll be using to set up live-reloading and debugging for Golang in a Dockerized development environment:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Docker&lt;/strong&gt; is the cornerstone of our setup, providing a reproducible and isolated environment for development. By leveraging Docker, we can ensure that our application behaves consistently between local development and production environments, minimizing any surprises caused by differences in OS or server configurations.&lt;/p&gt;

&lt;p&gt;For live-reloading. We'll use &lt;strong&gt;&lt;a href="https://github.com/air-verse/air" rel="noopener noreferrer"&gt;Air&lt;/a&gt;&lt;/strong&gt;, a lightweight Golang tool that monitors changes to your source code and automatically recompiles and restarts your server. While tools like Nodemon or Inotify-tools can achieve similar functionality, Air is specifically designed for Go, making it an ideal choice for this setup.&lt;/p&gt;

&lt;p&gt;Since Golang doesn’t have a built-in debugger, we’ll use &lt;strong&gt;&lt;a href="https://github.com/go-delve/delve" rel="noopener noreferrer"&gt;Delve&lt;/a&gt;&lt;/strong&gt; a robust debugging tool for Go. Delve integrates seamlessly with popular IDEs like Visual Studio Code, allowing us to set breakpoints, step through code, and inspect variables directly.&lt;/p&gt;

&lt;p&gt;Our objective is to create a development workflow where the server automatically reloads when changes are saved to the codebase. Debugging remains fully functional, enabling us to troubleshoot and inspect the application in real time (e.g., through Visual Studio Code’s built-in debugger).&lt;/p&gt;

&lt;h2&gt;
  
  
  Golang Server using Fiber
&lt;/h2&gt;

&lt;p&gt;Here's a minimal example of a Go server using the Fiber framework, which you can use to test your live-reload and debugging configuration. Create a file named main.go and add the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"github.com/gofiber/fiber/v2"&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;fiber&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;fiber&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Ctx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kt"&gt;error&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;str&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"Hello, World!"&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SendString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;

    &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;":3000"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is as simple as it gets—a lightweight server that responds with "Hello, World!" when accessed at &lt;a href="http://localhost:3000" rel="noopener noreferrer"&gt;http://localhost:3000&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Write &lt;code&gt;go run .&lt;/code&gt; in your terminal to test that out.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup Docker
&lt;/h2&gt;

&lt;p&gt;Here’s a basic docker-compose.yml file to start your api container. This example is minimal and can be extended to include other services like a database, Redis, or Nginx as needed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;api&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;context&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./api&lt;/span&gt;
      &lt;span class="na"&gt;dockerfile&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Dockerfile&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;3000:3000'&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;2345:2345'&lt;/span&gt;
    &lt;span class="na"&gt;stop_grace_period&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;0.1s&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./api:/app&lt;/span&gt;
    &lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;internal&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;build.context&lt;/code&gt;: used to tell docker-compose to check the &lt;code&gt;dockerfile&lt;/code&gt; present on the folder "api". I prefer to put my sources in another folder if I need to develop multiples other go services on this repository later on.&lt;br&gt;
&lt;code&gt;ports&lt;/code&gt;: expose the webserver running on port 3000. And we will expose port 2345 for the debugger server (we will define it later)&lt;br&gt;
&lt;code&gt;volumes&lt;/code&gt;: Bind directly to the container the content of the &lt;code&gt;/api&lt;/code&gt; folder (where all my go code is located on the Host) and put it to &lt;code&gt;/app&lt;/code&gt; on the docker volume. This way all changes to the project will visible directly to the docker container.&lt;/p&gt;
&lt;h2&gt;
  
  
  Dockerfile of the '/api' folder
&lt;/h2&gt;

&lt;p&gt;We saw previously that Docker-Compose is using the &lt;em&gt;dockerfile&lt;/em&gt; inside the &lt;code&gt;/api&lt;/code&gt; folder. Here is the content you should have for your dockerfile.&lt;/p&gt;

&lt;p&gt;Don't overthink the &lt;code&gt;delve&lt;/code&gt; and &lt;code&gt;air&lt;/code&gt; part. We will see how they work just after.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="c"&gt;# Use the official Golang image as the base image&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; golang:1.23.2-alpine3.20&lt;/span&gt;

&lt;span class="c"&gt;# Set the Current Working Directory inside the container&lt;/span&gt;
&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /app&lt;/span&gt;

&lt;span class="c"&gt;# Install delve, used to debug the application (golang doesn't have a built-in debugger)&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;go &lt;span class="nb"&gt;install &lt;/span&gt;github.com/go-delve/delve/cmd/dlv@latest

&lt;span class="c"&gt;# Install air, used to hot reload the application&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;go &lt;span class="nb"&gt;install &lt;/span&gt;github.com/air-verse/air@latest

&lt;span class="c"&gt;# Copy go mod and sum files and install dependencies&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; go.mod go.sum ./&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;go mod download

&lt;span class="c"&gt;# Switch to root user (if necessary, though it should work, do it only for development purposes)&lt;/span&gt;
&lt;span class="k"&gt;USER&lt;/span&gt;&lt;span class="s"&gt; root&lt;/span&gt;

&lt;span class="c"&gt;# Expose the ports of the container. Docker-Compose do it automatically but it's good to have it here&lt;/span&gt;
&lt;span class="k"&gt;EXPOSE&lt;/span&gt;&lt;span class="s"&gt; 2345&lt;/span&gt;
&lt;span class="k"&gt;EXPOSE&lt;/span&gt;&lt;span class="s"&gt; 3000&lt;/span&gt;

&lt;span class="c"&gt;# Run air for live-reload. The -c flag is used to specify the configuration file&lt;/span&gt;
&lt;span class="k"&gt;CMD&lt;/span&gt;&lt;span class="s"&gt; ["air", "-c", "air.toml"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Air and Delve setup
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Air&lt;/em&gt; will watch the source files of your project and reload your application when changes are saved. But since we also want to use &lt;em&gt;Delve&lt;/em&gt; as debugger, it is him (&lt;em&gt;delve&lt;/em&gt;) that will launch our server instead of &lt;em&gt;Air&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;For that, we will create a &lt;code&gt;air.toml&lt;/code&gt; file in the same place your DockerFile is placed (inside &lt;code&gt;/api&lt;/code&gt; folder).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="py"&gt;root&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"."&lt;/span&gt;
&lt;span class="py"&gt;tmp_dir&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"tmp"&lt;/span&gt;

&lt;span class="nn"&gt;[build]&lt;/span&gt;
&lt;span class="py"&gt;full_bin&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"dlv debug --build-flags=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s"&gt;-gcflags='all=-N -l'&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s"&gt; --listen 0.0.0.0:2345 --headless --continue --accept-multiclient --output=dist/debug"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This configuration tells air to run a specific command when the binary is recreated (when your server reload).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;dlv debug&lt;/code&gt;: It is the delve command that build and start your project with the debugger server attached to it.&lt;br&gt;
&lt;code&gt;--build-flags&lt;/code&gt;: Compile your golang program without optimization (make it faster to compile) but also without inline function (slower, but make your function accessible by the debugger).&lt;br&gt;
&lt;code&gt;--listen&lt;/code&gt;: Make your debugger server listen on the base host IP (&lt;em&gt;0.0.0.0&lt;/em&gt;, useful for your docker container) and on the port 2345.&lt;br&gt;
&lt;code&gt;--headless --continue --accept-multiclient&lt;/code&gt;: start directly your golang application with the debugger without waiting a client to connect to it first.&lt;br&gt;
&lt;code&gt;--output&lt;/code&gt;: Put the debug server compiled files into &lt;code&gt;dist/debug&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It is all we need to make live-reloading and debugging work together !&lt;/p&gt;
&lt;h2&gt;
  
  
  Setup VSCode debugger
&lt;/h2&gt;

&lt;p&gt;Now, last step, we need to tell VSCode how to access the debugging server.&lt;/p&gt;

&lt;p&gt;create a new debug configuration by creating a new file under &lt;code&gt;.vscode/launch.json&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"0.2.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"configurations"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Connect to container"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"go"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"debugAdapter"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dlv-dap"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"request"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"attach"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"mode"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"remote"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;The&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;container&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;port&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;host&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;must&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;match&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"port"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2345&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"host"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"localhost"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"trace"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"verbose"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"substitutePath"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="nl"&gt;"from"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/home/user/project/api"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"to"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/app"&lt;/span&gt;&lt;span class="p"&gt;}]&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;debugAdapter&lt;/code&gt;: We need to use that since the default debug adapter is not compatible with delve.&lt;br&gt;
&lt;code&gt;port&lt;/code&gt;: The port of the debugger server&lt;br&gt;
&lt;code&gt;host&lt;/code&gt;: The IP to connect to&lt;br&gt;
&lt;code&gt;substitutePath&lt;/code&gt;: This is the most useful setting, it will tell VSCode to match your host project path with the docker container volume project path. If you miss-configure this part, your breakpoints won't work since VSCode will be unable to match the line you set your breakpoint to with the docker container running application. &lt;/p&gt;

&lt;p&gt;And that's it ! Everything you need to have Live-Reload, Debugging and Docker working together. &lt;/p&gt;

</description>
      <category>go</category>
      <category>docker</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Colors for console.log with Deno</title>
      <dc:creator>Trystan Sarrade</dc:creator>
      <pubDate>Tue, 26 May 2020 11:33:42 +0000</pubDate>
      <link>https://dev.to/trystan_sarrade/colors-for-console-log-with-deno-no4</link>
      <guid>https://dev.to/trystan_sarrade/colors-for-console-log-with-deno-no4</guid>
      <description>&lt;p&gt;Chalk is a Nodejs package used to write console.log with colors. It's extremely useful for debugging your application by having easy to see big red highlights for your critical and error debug.&lt;/p&gt;

&lt;p&gt;If you are using Deno and wanted something similar, you are in the right place. &lt;/p&gt;

&lt;h2&gt;
  
  
  The different types of console debug
&lt;/h2&gt;

&lt;p&gt;JavaScript console has different levels of debug type. You have the common &lt;em&gt;console.log&lt;/em&gt; command. But you also have more of them. In Deno, those debugs have nothing different. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft6ipmdlnvf0c5v7mh2gm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft6ipmdlnvf0c5v7mh2gm.png" alt="Deno colors" width="453" height="226"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So let's add a little bit of colors to them !&lt;/p&gt;

&lt;h2&gt;
  
  
  Deno Color system
&lt;/h2&gt;

&lt;p&gt;Deno colors are similar to the chalk ones and are managers by one Deno standard library. Simply import the link &lt;em&gt;&lt;a href="https://deno.land/std/fmt/colors.ts" rel="noopener noreferrer"&gt;https://deno.land/std/fmt/colors.ts&lt;/a&gt;&lt;/em&gt; to your Deno code like this : &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fron02nxc82cam5t5260n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fron02nxc82cam5t5260n.png" alt="Deno colors" width="667" height="259"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Deno color system works by adding the function, "Colors.[the name of the color]" to your console.log parameter. Now we have pretty colorful debug. But we can do more !&lt;/p&gt;

&lt;h2&gt;
  
  
  Override default console functions
&lt;/h2&gt;

&lt;p&gt;Having to write the function Colors.red every time you need a red text is not easy to use. But you can override the default console functions with your own :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftqh2ec040jsw9vqim1nu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftqh2ec040jsw9vqim1nu.png" alt="Deno colors" width="706" height="651"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, every time you will use console.error in your application, a red prefix will follow your log everywhere inside your application. You should create another .ts script named something like "debug" or "console" and import it from your main application file at the beginning.&lt;/p&gt;

</description>
      <category>deno</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
