<?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: Koen Verburg</title>
    <description>The latest articles on DEV Community by Koen Verburg (@koenverburg).</description>
    <link>https://dev.to/koenverburg</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%2F518748%2F2ced3479-859d-41d8-8de2-e3c98cb81e2f.jpeg</url>
      <title>DEV Community: Koen Verburg</title>
      <link>https://dev.to/koenverburg</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/koenverburg"/>
    <language>en</language>
    <item>
      <title>Set up a Multi-Stage Docker Build for Go Applications</title>
      <dc:creator>Koen Verburg</dc:creator>
      <pubDate>Sun, 22 Aug 2021 11:13:14 +0000</pubDate>
      <link>https://dev.to/koenverburg/set-up-a-multi-stage-docker-build-for-go-applications-112k</link>
      <guid>https://dev.to/koenverburg/set-up-a-multi-stage-docker-build-for-go-applications-112k</guid>
      <description>&lt;p&gt;We are going to create a simple multi-stage Docker build setup for Go applications. It might sound daunting at first, but it's actually really easy.&lt;/p&gt;

&lt;p&gt;A multi-stage Docker build serves a few purposes. First, the final image size is smaller than traditional images, second, it's more secure.&lt;/p&gt;

&lt;p&gt;Using dockers layering, we can abstract the building processes into multiple stages. And only copy the output that we need for the next stage. For example, the binary that gets created we're running &lt;code&gt;go build -o main&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The goal here is to end up with a docker image that only contains and runs the final binary. What that final binary is, does not really matter in this context. But in this article, I'm going to use a simple script that outputs text to the console.&lt;/p&gt;

&lt;h3&gt;
  
  
  Requirements
&lt;/h3&gt;

&lt;p&gt;We are going to need the following tooling, so make sure you installed it on your machine.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go 1.x or higher&lt;/li&gt;
&lt;li&gt;Docker&lt;/li&gt;
&lt;li&gt;VSCode or any other editor&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Let's write some code
&lt;/h3&gt;

&lt;p&gt;Let's create the folder structure so that we have a good base to build from.&lt;br&gt;
Make a directory called &lt;code&gt;src&lt;/code&gt; and &lt;code&gt;cd&lt;/code&gt; into that.&lt;/p&gt;

&lt;p&gt;Now, let's initialize our go package with the following command &lt;code&gt;go mod init hello-world&lt;/code&gt;. This will create a file called &lt;code&gt;go.mod&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;With that part done, let's write a simple Hello World in Go.&lt;br&gt;
Create a file called &lt;code&gt;main.go&lt;/code&gt; in our &lt;code&gt;src&lt;/code&gt; directory 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;"fmt"&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;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello World!"&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;If you run this using, &lt;code&gt;go run main.go&lt;/code&gt; the output would be &lt;code&gt;Hello World!&lt;/code&gt;.&lt;br&gt;
Great, with that part out of the way, we can start with diving into Docker!&lt;/p&gt;
&lt;h3&gt;
  
  
  Golang base image
&lt;/h3&gt;

&lt;p&gt;Change directory (&lt;code&gt;cd ..&lt;/code&gt;) to the project root, here we are going to create a &lt;code&gt;dockerfile&lt;/code&gt;. Paste in the following code and then I will explain what we are doing.&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="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; golang:1.16-alpine&lt;/span&gt;

&lt;span class="c"&gt;# Create a workspace for the app&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;# Download necessary Go modules&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; src/go.mod .&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;go mod download

&lt;span class="c"&gt;# Copy over the source files&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; src/*.go ./&lt;/span&gt;

&lt;span class="c"&gt;# Build&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;go build &lt;span class="nt"&gt;-o&lt;/span&gt; /main

&lt;span class="k"&gt;ENTRYPOINT&lt;/span&gt;&lt;span class="s"&gt; ["/main"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we are going to do a few things, on the &lt;code&gt;FROM&lt;/code&gt; line we are going to specify which base image we are going to use.&lt;br&gt;
Setting a &lt;code&gt;WORKDIR&lt;/code&gt; is like setting a special folder from which we are going to work.&lt;br&gt;
Then we are to copy over our &lt;code&gt;go.mod&lt;/code&gt; and download our packages if needed. And then we are going to copy over our source code.&lt;/p&gt;

&lt;p&gt;After this we are ready to build our go application, we do that using, &lt;code&gt;RUN go build -o /main&lt;/code&gt;.&lt;br&gt;
Now that we have created a single binary, we can set that as our entrypoint when we run our docker image.&lt;/p&gt;

&lt;p&gt;To build our image, we will use &lt;code&gt;docker build . -t hello-world-golang1.16&lt;/code&gt;, this will build the image.&lt;br&gt;
After the build has finished. We can run our image as a container using the command &lt;code&gt;docker run hello-world-golang1.16&lt;/code&gt; to test if this works.&lt;br&gt;
And you should get an output like &lt;code&gt;Hello World!&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Let's also check what the size is of our image. Using the command, &lt;code&gt;docker images&lt;/code&gt; we can see the size.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REPOSITORY               TAG       IMAGE ID       CREATED              SIZE
hello-world-golang1.16   latest    68b776701cbe   About a minute ago   304MB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Wow, that is a heavy image! Coming in at 304 MB. Let's try to cut off some fat here.&lt;/p&gt;

&lt;p&gt;During my research on using multi-stage Docker builds. I saw that the Docker documentation used a Debian base image. Because of that, I wanted to also include it here as well.&lt;/p&gt;

&lt;p&gt;Let's replace our &lt;code&gt;dockerfile&lt;/code&gt; that we created earlier with the following. Note here the two comments, Builder and Runner. The Builder part is for building the go application and nothing more. The same can be said for the Runner part because that's sole purpose is running our application.&lt;/p&gt;

&lt;p&gt;The builder has  &lt;code&gt;golang:1.6-alpine&lt;/code&gt; as base image because it needs to have the &lt;code&gt;Go&lt;/code&gt; binary in its path. Because Go compiles to a single binary, running it does not need the presence of Go. So we can use a base image from Debian for our final image that will run our application.&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;#&lt;/span&gt;
&lt;span class="c"&gt;# Builder&lt;/span&gt;
&lt;span class="c"&gt;#&lt;/span&gt;

&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; golang:1.16-alpine AS builder&lt;/span&gt;

&lt;span class="c"&gt;# Create a workspace for the app&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;# Download necessary Go modules&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; src/go.mod .&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;go mod download

&lt;span class="c"&gt;# Copy over the source files&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; src/*.go ./&lt;/span&gt;

&lt;span class="c"&gt;# Build&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;go build &lt;span class="nt"&gt;-o&lt;/span&gt; /main

&lt;span class="c"&gt;#&lt;/span&gt;
&lt;span class="c"&gt;# Runner&lt;/span&gt;
&lt;span class="c"&gt;#&lt;/span&gt;

&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; gcr.io/distroless/base-debian10 AS runner&lt;/span&gt;

&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /&lt;/span&gt;

&lt;span class="c"&gt;# Copy from builder the final binary&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; --from=builder /main /main&lt;/span&gt;

&lt;span class="k"&gt;USER&lt;/span&gt;&lt;span class="s"&gt; nonroot:nonroot&lt;/span&gt;

&lt;span class="k"&gt;ENTRYPOINT&lt;/span&gt;&lt;span class="s"&gt; ["/main"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I'm changing the build command, so we don't overwrite the image we created earlier. This way we can see what our changes are doing to the final docker image.&lt;/p&gt;

&lt;p&gt;Build our new image using &lt;code&gt;docker build . -t hello-world-debian&lt;/code&gt;. Let's see if this changed the behavior of the container &lt;code&gt;docker run hello-world-debian&lt;/code&gt;. And you should get the same output as before: &lt;code&gt;Hello World!&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Let's check size using &lt;code&gt;docker images&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REPOSITORY               TAG       IMAGE ID       CREATED              SIZE
hello-world-debian       latest    7ad8a5965a06   About a minute ago   21.1MB
hello-world-golang1.16   latest    68b776701cbe   About a minute ago   304MB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look at that, 21.1 MB, that is a significant reduction in size!&lt;/p&gt;

&lt;p&gt;Awesome, but can we push it even more? Yes, we can!&lt;/p&gt;

&lt;p&gt;Using the smallest docker base image that there is.&lt;br&gt;
Which is &lt;code&gt;scratch&lt;/code&gt;. This is as bare as it gets. In the runner part of the docker file, change out the &lt;code&gt;FROM&lt;/code&gt;statement to &lt;code&gt;scratch&lt;/code&gt; like below.&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;#&lt;/span&gt;
&lt;span class="c"&gt;# Runner&lt;/span&gt;
&lt;span class="c"&gt;#&lt;/span&gt;

&lt;span class="c"&gt;# FROM gcr.io/distroless/base-debian10 AS runner&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; scratch AS runner&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Build our new image using &lt;code&gt;docker build . -t hello-world-scratch&lt;/code&gt;.&lt;br&gt;
Let's see if this changed the behavior of the container &lt;code&gt;docker run hello-world-scratch&lt;/code&gt;. And you should get the same output as before: &lt;code&gt;Hello World!&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Let's check the size once more, using &lt;code&gt;docker images&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REPOSITORY               TAG       IMAGE ID       CREATED              SIZE
hello-world-scratch      latest    eb41c9777973   58 seconds ago       1.94MB
hello-world-debian       latest    7ad8a5965a06   About a minute ago   21.1MB
hello-world-golang1.16   latest    68b776701cbe   About a minute ago   304MB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Would you look at that, 1.94 MB! That is perfect!&lt;/p&gt;

&lt;h3&gt;
  
  
  Wrapping it up
&lt;/h3&gt;

&lt;p&gt;I hope I have inspired you to use multi-stage Docker builds for your next project. This is still a simple two-stage Docker build, you can even use more stages if you need or when your project asks for it.&lt;/p&gt;

&lt;p&gt;Here is a few useful links and also the source code, so you can try it out for yourself.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://golang.org"&gt;Golang&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.docker.com/language/golang/build-images/#multi-stage-builds"&gt;Docker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/koenverburg/article-source-code/tree/main/multi-stage-docker-build-go"&gt;Source code&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>docker</category>
      <category>go</category>
      <category>containers</category>
      <category>devops</category>
    </item>
    <item>
      <title>Publish an Article To DEV.to With GO</title>
      <dc:creator>Koen Verburg</dc:creator>
      <pubDate>Sun, 16 May 2021 20:46:09 +0000</pubDate>
      <link>https://dev.to/koenverburg/publish-an-article-to-dev-to-with-go-5am7</link>
      <guid>https://dev.to/koenverburg/publish-an-article-to-dev-to-with-go-5am7</guid>
      <description>&lt;p&gt;We are going to create a program that allows us to post draft articles from Markdown to &lt;a href="https://dev.to"&gt;DEV.to&lt;/a&gt; with ease.&lt;/p&gt;

&lt;h3&gt;
  
  
  Requirements
&lt;/h3&gt;

&lt;p&gt;We are going to need the following tooling so make sure it is installed on your machine.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go 1.x or higher&lt;/li&gt;
&lt;li&gt;VS Code or any other editor&lt;/li&gt;
&lt;li&gt;Any terminal&lt;/li&gt;
&lt;li&gt;A DEV.to account&lt;/li&gt;
&lt;li&gt;A DEV.to API key&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Getting Started
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. Scaffolding the project&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First, let's set up the project structure so have a base to work on.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;devAutomation &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;devAutomation

&lt;span class="nb"&gt;touch&lt;/span&gt; .env
&lt;span class="nb"&gt;touch &lt;/span&gt;main.go

go mod init devAutomation

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"# Hello Dev.To
Lorem ipsum dolor sit amet, consectetur adipiscing elit."&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; example.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we are doing a few things, on the first line, we are creating a directory for our project and changing directory into that folder.&lt;/p&gt;

&lt;p&gt;Secondly, we are creating a few files. The &lt;code&gt;.env&lt;/code&gt; file is for the environment variables like the API key which we are getting in step 2. And the  &lt;code&gt;main.go&lt;/code&gt;  is the starting point of our program.&lt;/p&gt;

&lt;p&gt;Then we need to initialize the module using &lt;code&gt;go mod init&lt;/code&gt; and lastly we need an example Markdown file to post to DEV.to.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Getting the API key&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's get the API key go to &lt;a href="https://dev.to/settings/account"&gt;this page&lt;/a&gt; and scroll down to the section named "DEV API Keys". Create a new API key and name accordingly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F7wt1vbx3u8o0xgwnwddb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F7wt1vbx3u8o0xgwnwddb.png" alt="DEV API Keys"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's save the API key in the &lt;code&gt;.env&lt;/code&gt; file we created in step 1.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="py"&gt;DEV_TO_API_KEY&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;'your-api-key'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3.  Reading Markdown&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Reading the Markdown file is quite easy. We are going to read the example markdown using &lt;code&gt;ioutil.ReadFile&lt;/code&gt; and using &lt;code&gt;fmt.Println&lt;/code&gt; we are for now printing the contents to the terminal.&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;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;file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;ioutil&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ReadFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"./example.md"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file&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;You should have an output looking like the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Hello Dev.To
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4.  Creating the API Request&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The API call is the hardest part of this tutorial. First, we need some types. These are needed to ensure the data we are posting to the API will get through correctly.&lt;/p&gt;

&lt;p&gt;Using these types we can also see that what we can send over to the API.&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;type&lt;/span&gt; &lt;span class="n"&gt;DevTo&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Article&lt;/span&gt; &lt;span class="n"&gt;Article&lt;/span&gt; &lt;span class="s"&gt;`json:"article"`&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Article&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Title&lt;/span&gt;        &lt;span class="kt"&gt;string&lt;/span&gt;   &lt;span class="s"&gt;`json:"title"`&lt;/span&gt;
    &lt;span class="n"&gt;Published&lt;/span&gt;    &lt;span class="kt"&gt;bool&lt;/span&gt;     &lt;span class="s"&gt;`json:"published"`&lt;/span&gt;
    &lt;span class="n"&gt;Series&lt;/span&gt;       &lt;span class="kt"&gt;string&lt;/span&gt;   &lt;span class="s"&gt;`json:"series"`&lt;/span&gt;
    &lt;span class="n"&gt;MainImage&lt;/span&gt;    &lt;span class="kt"&gt;string&lt;/span&gt;   &lt;span class="s"&gt;`json:"main_image"`&lt;/span&gt;
    &lt;span class="n"&gt;Canonical&lt;/span&gt;    &lt;span class="kt"&gt;string&lt;/span&gt;   &lt;span class="s"&gt;`json:"canonical_url"`&lt;/span&gt;
    &lt;span class="n"&gt;Description&lt;/span&gt;  &lt;span class="kt"&gt;string&lt;/span&gt;   &lt;span class="s"&gt;`json:"description"`&lt;/span&gt;
    &lt;span class="n"&gt;Tags&lt;/span&gt;         &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="s"&gt;`json:"tags"`&lt;/span&gt;
    &lt;span class="n"&gt;BodyMarkdown&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;   &lt;span class="s"&gt;`json:"body_markdown"`&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's create a new function called &lt;code&gt;publish&lt;/code&gt; and create the request logic in there.&lt;br&gt;
For the sake of this demo, I will split the example markdown file on a new line so we have a separate title and body for our article.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;For more advanced articles please take a look at the &lt;a href="https://docs.dev.to/api/#operation/createArticle"&gt;Frontmatter&lt;/a&gt; options that DEV.to supports.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In this part, we will create the &lt;code&gt;responseBody&lt;/code&gt;  and add our data.&lt;br&gt;
Then we create the &lt;code&gt;payload&lt;/code&gt; and added it to the request.&lt;/p&gt;

&lt;p&gt;After that, we are doing a few if checks to make sure we get the appropriate log message printed to the terminal when the API call fails, succeeds, or returns with another status 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;func&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"https://dev.to/api/articles"&lt;/span&gt;
    &lt;span class="n"&gt;content&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;strings&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;responseBody&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;DevTo&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Article&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Article&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;Published&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;    &lt;span class="no"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c"&gt;// this will ensure it's a draft&lt;/span&gt;
            &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;        &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
            &lt;span class="n"&gt;BodyMarkdown&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Marshal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;responseBody&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NewRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"POST"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NewBuffer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Header&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"api-key"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;apikey&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Header&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Content-Type"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"application/json"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Client&lt;/span&gt;&lt;span class="p"&gt;{}&lt;/span&gt;
    &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Do&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Fatalln&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;defer&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Body&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Close&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;StatusCode&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;StatusCode&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="m"&gt;201&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Created new article on Dev.To"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;StatusCode&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;StatusCode&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="m"&gt;201&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;responseMessage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;ioutil&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ReadAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Body&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Fatalln&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;responseMessage&lt;/span&gt;&lt;span class="p"&gt;))&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;&lt;strong&gt;5. Loading in the API key&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We also need to set the API to authorize the post request. For this, we will need the &lt;code&gt;godotenv&lt;/code&gt; module to read the &lt;code&gt;.env&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go get github.com/joho/godotenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we have a utility function to get the API key. On the first line, we are reading the &lt;code&gt;.env&lt;/code&gt; file and if there is an error we will print that. Otherwise, it's correctly read and we print a message that it's correctly loaded in.&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;func&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;godotenv&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"./.env"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Fatalf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Error loading .env file"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Loaded the .env file"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&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;Revisited the &lt;code&gt;request&lt;/code&gt; function we created in step 4, and add the following line.&lt;br&gt;
If you have kept a close eye you would have spotted that &lt;code&gt;apikey&lt;/code&gt; wasn't declared.&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="c"&gt;// ... other code&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;apikey&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"DEV_TO_API_KEY"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;// &amp;lt;-- this line&lt;/span&gt;
    &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"https://dev.to/api/articles"&lt;/span&gt;
    &lt;span class="n"&gt;content&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;strings&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c"&gt;// ...rest of the function&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. Connecting all the pieces&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now go back to the &lt;code&gt;main&lt;/code&gt; function we created in step 3. And add the following line.&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;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;file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;ioutil&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ReadFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"./example.md"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="c"&gt;// &amp;lt;-- this line&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will bootstrap all the functions we created and pass along the contents of the markdown file.&lt;/p&gt;

&lt;p&gt;If you run this in the terminal you should see the following output&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;18:51:36 Loaded the .env file
18:51:37 Created new article on Dev.To
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open up your DEV.to &lt;a href="https://dev.to/dashboard"&gt;dashboard&lt;/a&gt;, and you should see a new entry be listed there.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fccd23out5ii7f85ti9ml.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fccd23out5ii7f85ti9ml.png" alt="New Post in Dev.to"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fn32b6o31iq7a92ppi2rp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fn32b6o31iq7a92ppi2rp.png" alt="New post detail page"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Wrapping it up.
&lt;/h3&gt;

&lt;p&gt;Congrats, you now have a program to upload your Markdown-based articles to Dev.to using Golang.&lt;/p&gt;

</description>
      <category>go</category>
      <category>automation</category>
      <category>scripting</category>
      <category>cli</category>
    </item>
    <item>
      <title>Here Is My List of Technologies I'm Learning in 2021</title>
      <dc:creator>Koen Verburg</dc:creator>
      <pubDate>Tue, 23 Mar 2021 21:13:00 +0000</pubDate>
      <link>https://dev.to/koenverburg/here-is-my-list-of-technologies-i-m-learning-in-2021-272</link>
      <guid>https://dev.to/koenverburg/here-is-my-list-of-technologies-i-m-learning-in-2021-272</guid>
      <description>&lt;p&gt;This year I want to set a list of topics that I want to learn for this year.&lt;br&gt;
At the end of the year, I will reflect on how much of the lists I have achieved.&lt;/p&gt;



&lt;h2&gt;
  
  
  1. &lt;a href="https://en.wikipedia.org/wiki/Functional_programming"&gt;Functional Programming&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;A simple gist of Functional Programming is all about functions for immutable variables. In contrast to Object-Oriented languages, which are more about a fixed set of functions and modifying or adding new variables.&lt;/p&gt;

&lt;p&gt;A year ago I had my first go at it when I worked with Elixir but now that I don't use it anymore, it has faded a bit. And because Functional Programming has always intrigued me. I want to pick it up again.&lt;/p&gt;

&lt;p&gt;In this year I will experiment with the concept of Functional Programming, what it is and what makes it functional? And how do Functional Programming Languages like Elixir and Haskell use these practices?&lt;/p&gt;

&lt;p&gt;I will go back to Elixir to learn Functional Programming, but also I want to use these practices in other languages like TypeScript, C#, and Go. Because I use those on a daily basis.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. &lt;a href="https://golang.org"&gt;Golang&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Golang is created by Google and it's getting more and more adoption by large companies and Open-Source Software Projects. Think about Docker and Kubernetes which are quite popular for what they are, but they are also written in Go.&lt;/p&gt;

&lt;p&gt;A few months ago Github Released their Profile Readme's and a Hypetrain started, Everyone was creating and polishing their Profile Readme's.&lt;/p&gt;

&lt;p&gt;I looked around and saw there were a few people that create an auto-generating readme based on a cron schedule. I wanted that as well and started to think about which language to use for this. I could write it Python or NodeJS but I wanted something completely new, So I settled for Go.&lt;/p&gt;

&lt;p&gt;Since then I have written small CLI programs in Go. But I'm still scratching the surface of the language but during this year I will write most of my APIs, Web Scrappers, and CLI tools in Go.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. &lt;a href="https://www.docker.com"&gt;Docker&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Docker is a set of tools for developing, running, and shipping your applications.&lt;br&gt;&lt;br&gt;
It allows for a simple Command Line Interface. And it separates your application runtime from the infrastructure it is running on.&lt;/p&gt;

&lt;p&gt;I'm familiar with Docker and have run my personal website on Docker in production for a long time. Because I also want to educate other people on Docker I have to dive into it a bit deeper. Besides that, I also want to learn about networking, routing, and load balancing.&lt;/p&gt;

&lt;p&gt;During this year I'm going to write Go programs and run those in Docker. What those programs will be, I don't know yet. Maybe a Slackbot or a simple website using Go.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. &lt;a href="https://www.terraform.io"&gt;Terraform&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Terraform is an open-source Infrastructure As Code tool that allows for managing the cloud by defining it as readable configuration files.&lt;/p&gt;

&lt;p&gt;What I like about Terraform is that you just specify your &lt;a href="https://registry.terraform.io/browse/providers"&gt;cloud provider&lt;/a&gt; and you are ready to create and document your Infrastructure as code. With the documentation nearby you can scaffold your Infrastructure pretty fast.&lt;/p&gt;

&lt;p&gt;That this time I have used Terraform for only one project at work and personal prototypes. But the exposure I got was enough for me to know that this is a great tool for me to use.&lt;/p&gt;

&lt;p&gt;During this year I want to set up more projects in the cloud with Terraform, think about VM's, &lt;a href="https://docs.microsoft.com/en-us/azure/aks"&gt;AKS&lt;/a&gt; resources, and full DTAP-Streets with traditional App Services in Azure.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. &lt;a href="https://kubernetes.io"&gt;Kubernetes&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Kubernetes is a container orchestration system to manage, scale and deploy your applications.&lt;/p&gt;

&lt;p&gt;Kubernetes is still a new topic for me and I'm still scratching the surface on what I can do with it. But I think this is the future of managing your apps in the cloud.&lt;/p&gt;

&lt;p&gt;I want to make sure that every project I deliver will be reliable and can handle any load the visitors can throw at it during Black Friday or other campaigns.&lt;/p&gt;

&lt;p&gt;I'm currently running a &lt;a href="https://k3s.io"&gt;k3s&lt;/a&gt; cluster on a set of Raspberry Pis at home. I'm documenting my progress in &lt;a href="https://github.com/koenverburg/cloudfiles"&gt;this repository&lt;/a&gt;. &lt;em&gt;(small disclaimer: I'm merely documenting it for myself do not expect documentation grade reading materials at this point in time)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;During this year I will setup k8s from scratch on VM's and later I want to look at what &lt;a href="https://docs.microsoft.com/en-us/azure/aks"&gt;AKS (Azure Kubernetes Service)&lt;/a&gt; brings to the table.&lt;/p&gt;




&lt;p&gt;That's the list, thank you for reading! What are you learning this year?&lt;/p&gt;

&lt;p&gt;Be sure to follow me on Medium, Instagram, and Twitter where you can follow along with the process.&lt;/p&gt;

&lt;p&gt;Links of the topics I talked about&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Functional_programming"&gt;Functional Programming&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://golang.org"&gt;Golang&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.docker.com"&gt;Docker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.terraform.io"&gt;Terraform&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kubernetes.io"&gt;Kubernetes&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>functional</category>
      <category>docker</category>
      <category>kubernetes</category>
      <category>go</category>
    </item>
  </channel>
</rss>
