<?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: Gospel Lekia</title>
    <description>The latest articles on DEV Community by Gospel Lekia (@goslek).</description>
    <link>https://dev.to/goslek</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%2F159290%2F489de690-bbb1-43a1-8174-6b193a32612b.jpeg</url>
      <title>DEV Community: Gospel Lekia</title>
      <link>https://dev.to/goslek</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/goslek"/>
    <language>en</language>
    <item>
      <title>New article alert</title>
      <dc:creator>Gospel Lekia</dc:creator>
      <pubDate>Mon, 09 Feb 2026 13:52:46 +0000</pubDate>
      <link>https://dev.to/goslek/new-article-alert-3bmo</link>
      <guid>https://dev.to/goslek/new-article-alert-3bmo</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/goslek" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&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%2Fuser%2Fprofile_image%2F159290%2F489de690-bbb1-43a1-8174-6b193a32612b.jpeg" alt="goslek"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/goslek/the-software-engineers-role-in-the-ai-era-eoi" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;The Software Engineers' Role in the AI Era&lt;/h2&gt;
      &lt;h3&gt;Gospel Lekia ・ Feb 9&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#ai&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#webdev&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#programming&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#software&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>ai</category>
      <category>webdev</category>
      <category>programming</category>
      <category>software</category>
    </item>
    <item>
      <title>The Software Engineers' Role in the AI Era</title>
      <dc:creator>Gospel Lekia</dc:creator>
      <pubDate>Mon, 09 Feb 2026 06:16:49 +0000</pubDate>
      <link>https://dev.to/goslek/the-software-engineers-role-in-the-ai-era-eoi</link>
      <guid>https://dev.to/goslek/the-software-engineers-role-in-the-ai-era-eoi</guid>
      <description>&lt;p&gt;Artificial Intelligence is no longer a future idea. It’s already here. From chatbots and recommendation systems to code assistants and self-driving cars, AI is becoming part of everyday software. This shift has naturally raised questions, especially among software engineers: Will AI replace us? What is our role now?&lt;/p&gt;

&lt;p&gt;The short answer is simple: software engineers are more important than ever, just in a different way. So, there is nothing to really worry about.&lt;/p&gt;

&lt;h2&gt;
  
  
  From Writing Code to Solving Problems
&lt;/h2&gt;

&lt;p&gt;In the past, a large part of a software engineer’s job was writing code line by line. Today, AI tools can help generate code, fix bugs, and suggest improvements. This doesn’t make engineers less useful; it changes the focus of their work.&lt;/p&gt;

&lt;p&gt;Modern software engineers spend more time understanding problems, designing systems, and making decisions. AI can write code, but it cannot fully understand business needs, user behaviour, or real-world constraints. Engineers bridge that gap. One of the things engineers need to understand is the &lt;em&gt;first principles&lt;/em&gt; of how things work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building and Shaping AI Systems
&lt;/h2&gt;

&lt;p&gt;AI systems don’t build themselves. Software engineers design the infrastructure that AI runs on, integrate AI models into applications, and ensure everything works reliably at scale. They decide how data flows, how models are deployed, and how systems stay secure and fast.&lt;/p&gt;

&lt;p&gt;Without solid engineering, even the smartest AI model is useless.&lt;/p&gt;

&lt;h2&gt;
  
  
  Responsible and Ethical Development
&lt;/h2&gt;

&lt;p&gt;Humans are better at making judgments.&lt;br&gt;
AI can have serious consequences—biased decisions, privacy issues, and unintended harm. Software engineers play a key role in preventing this. They choose how data is collected, how models are used, and what safeguards are in place.&lt;/p&gt;

&lt;p&gt;In the AI era, engineers are not just builders; they are guardians. They help ensure AI is fair, transparent, and safe for users.&lt;br&gt;
It is in the place of the engineers to ensure compliance, governance and security checks are in place even for vibe-coded software or AI-generated code. Speaking of checklist here is a good one you can use &lt;a href="https://github.com/Yigaue/production-ready-web-api-checklist" rel="noopener noreferrer"&gt;production-ready web-api checklist&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Working With AI, Not Against It
&lt;/h2&gt;

&lt;p&gt;The best engineers don’t compete with AI. They collaborate with it. AI tools can speed up development, reduce repetitive work, and help engineers focus on creative and complex tasks.&lt;/p&gt;

&lt;p&gt;Knowing how to use AI effectively is becoming a core engineering skill, just like knowing a programming language or a framework.&lt;/p&gt;

&lt;h2&gt;
  
  
  Continuous Learning Is Now Essential
&lt;/h2&gt;

&lt;p&gt;Technology has always changed, but AI is accelerating that change. Software engineers must keep learning about AI basics, data, system design, and new tools. The goal isn’t to become a machine learning expert overnight, but to understand enough to make smart decisions.&lt;br&gt;
Also, LLMs are not as good yet. The knowledge on which they relied comes from the public and engineers. We need to continually feed it the right techniques and knowledge to improve the system.&lt;/p&gt;

&lt;p&gt;Those who adapt will thrive.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The AI era is not the end of software engineering. It’s an evolution. Software engineers are shifting from pure coders to problem solvers, system designers, and ethical decision-makers. AI is a powerful tool, but it still needs human judgment, creativity, and responsibility.&lt;/p&gt;

&lt;p&gt;In the end, AI doesn’t replace software engineers. It raises the bar—and creates new opportunities for those ready to grow.&lt;/p&gt;

&lt;p&gt;What other ways do you think engineers can improve and thrive? Leave your response in the comments.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>programming</category>
      <category>software</category>
    </item>
    <item>
      <title>A Beginner-friendly Approach to Developing a REST API with Go, Gin and MSQL</title>
      <dc:creator>Gospel Lekia</dc:creator>
      <pubDate>Wed, 21 Feb 2024 18:17:24 +0000</pubDate>
      <link>https://dev.to/goslek/a-beginner-friendly-approach-to-developing-a-rest-api-with-go-gin-and-msql-1ogm</link>
      <guid>https://dev.to/goslek/a-beginner-friendly-approach-to-developing-a-rest-api-with-go-gin-and-msql-1ogm</guid>
      <description>&lt;p&gt;Mastering Go is an effort worth sticking to. It is challenging when you attempt to learn everything in a day. The beginner-friend tutorial series is an honest effort to teach key concepts in bitwise and practical ways. This is the continuation and second part of this tutorial. See the first part here: &lt;a href="https://dev.to/goslek/a-beginner-friendly-approach-to-developing-a-rest-api-with-go-and-gin-301p"&gt;A Beginner-friendly Approach to Developing a REST API with Go and Gin&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What We are building on
&lt;/h2&gt;

&lt;p&gt;Here is our current code and structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;|- go.mod
|- go.sum
|- main.go
|- readme.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;main.go/&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="m"&gt;1&lt;/span&gt; &lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;
&lt;span class="m"&gt;2&lt;/span&gt;
&lt;span class="m"&gt;3&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="m"&gt;4&lt;/span&gt;   &lt;span class="s"&gt;"github.com/gin-gonic/gin"&lt;/span&gt;
&lt;span class="m"&gt;5&lt;/span&gt;   &lt;span class="s"&gt;"net/http"&lt;/span&gt;
&lt;span class="m"&gt;6&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="m"&gt;7&lt;/span&gt;
&lt;span class="m"&gt;8&lt;/span&gt; &lt;span class="c"&gt;// book struct represents data about a book record.&lt;/span&gt;
&lt;span class="m"&gt;9&lt;/span&gt; &lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;book&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="m"&gt;10&lt;/span&gt;  &lt;span class="n"&gt;ID&lt;/span&gt;     &lt;span class="kt"&gt;string&lt;/span&gt;  &lt;span class="s"&gt;`json:"id"`&lt;/span&gt;
&lt;span class="m"&gt;11&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="m"&gt;12&lt;/span&gt;  &lt;span class="n"&gt;Author&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;  &lt;span class="s"&gt;`json:"author"`&lt;/span&gt;
&lt;span class="m"&gt;13&lt;/span&gt;  &lt;span class="n"&gt;Price&lt;/span&gt;  &lt;span class="kt"&gt;float64&lt;/span&gt; &lt;span class="s"&gt;`json:"price"`&lt;/span&gt;
&lt;span class="m"&gt;14&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="m"&gt;15&lt;/span&gt;
&lt;span class="m"&gt;16&lt;/span&gt; &lt;span class="c"&gt;// books slice to seed record to book store.&lt;/span&gt;
&lt;span class="m"&gt;17&lt;/span&gt; &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;books&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="n"&gt;book&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="m"&gt;18&lt;/span&gt;  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"A Day in the Life of Abed Salama"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
&lt;span class="m"&gt;19&lt;/span&gt; &lt;span class="n"&gt;Author&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Nathan Thrall"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;56.99&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="m"&gt;20&lt;/span&gt;  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"King: A life"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Author&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Jonathan 
21 Eig"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;56.99&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="m"&gt;22&lt;/span&gt;  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Where we go from here"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Author&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; 
&lt;span class="m"&gt;23&lt;/span&gt; &lt;span class="s"&gt;"Bernie Sanders"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;17.99&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="m"&gt;24&lt;/span&gt;  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"4"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Buiding a dream server"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Author&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; 
&lt;span class="m"&gt;25&lt;/span&gt; &lt;span class="s"&gt;"Yiga ue"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;39.99&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="m"&gt;26&lt;/span&gt;  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"5"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Clean Code "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Author&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Robert C 
27 Martin"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;39.99&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="m"&gt;28&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="m"&gt;29&lt;/span&gt;
&lt;span class="m"&gt;30&lt;/span&gt; &lt;span class="c"&gt;// getBooks responds with the list of all books as json&lt;/span&gt;
&lt;span class="m"&gt;31&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;getBooks&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;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="m"&gt;32&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;IndentedJSON&lt;/span&gt;&lt;span class="p"&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;StatusOK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;books&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="m"&gt;33&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="m"&gt;34&lt;/span&gt;
&lt;span class="m"&gt;35&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="m"&gt;36&lt;/span&gt;  &lt;span class="n"&gt;router&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Default&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="m"&gt;37&lt;/span&gt;  &lt;span class="n"&gt;router&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;"/books"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;getBooks&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="m"&gt;38&lt;/span&gt;  &lt;span class="n"&gt;router&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;"/books/:id"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;getBook&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="m"&gt;39&lt;/span&gt;  &lt;span class="n"&gt;router&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;POST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/books"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;postBook&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="m"&gt;40&lt;/span&gt;  &lt;span class="n"&gt;router&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"localhost:8080"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="m"&gt;41&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="m"&gt;42&lt;/span&gt;
&lt;span class="m"&gt;43&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;getBook&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;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="m"&gt;44&lt;/span&gt;  &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&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;Param&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="m"&gt;45&lt;/span&gt;  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;book&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;range&lt;/span&gt; &lt;span class="n"&gt;books&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="m"&gt;46&lt;/span&gt;      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;book&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="m"&gt;47&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;IndentedJSON&lt;/span&gt;&lt;span class="p"&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;StatusOK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;book&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="m"&gt;48&lt;/span&gt;          &lt;span class="k"&gt;return&lt;/span&gt;
&lt;span class="m"&gt;49&lt;/span&gt;      &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="m"&gt;50&lt;/span&gt;  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="m"&gt;51&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;IndentedJSON&lt;/span&gt;&lt;span class="p"&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;StatusNotFound&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;H&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"message"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; 
&lt;span class="m"&gt;52&lt;/span&gt; &lt;span class="s"&gt;"book not found"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="m"&gt;53&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="m"&gt;54&lt;/span&gt;
&lt;span class="m"&gt;55&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;postBook&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;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="m"&gt;56&lt;/span&gt;  &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;newBook&lt;/span&gt; &lt;span class="n"&gt;book&lt;/span&gt;
&lt;span class="m"&gt;57&lt;/span&gt;
&lt;span class="m"&gt;58&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="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BindJSON&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;newBook&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="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="m"&gt;59&lt;/span&gt;      &lt;span class="k"&gt;return&lt;/span&gt;
&lt;span class="m"&gt;60&lt;/span&gt;  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="m"&gt;61&lt;/span&gt;
&lt;span class="m"&gt;62&lt;/span&gt;  &lt;span class="n"&gt;books&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;books&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;newBook&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="m"&gt;63&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;IndentedJSON&lt;/span&gt;&lt;span class="p"&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;StatusCreated&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;newBook&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="m"&gt;64&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="m"&gt;65&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is a linear structure where everything is in the main.go file. let's add structure bit by bit as we go along the tutorial.&lt;/p&gt;

&lt;h2&gt;
  
  
  Restructuring
&lt;/h2&gt;

&lt;p&gt;To focus on learning, we will not do so much with the application's structure. However, we will add a little structure to the application.&lt;/p&gt;

&lt;p&gt;Create a new &lt;code&gt;models&lt;/code&gt; directory in the root and add a file name &lt;code&gt;book.go&lt;/code&gt; to it.&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;models 
&lt;span class="nb"&gt;touch &lt;/span&gt;models/book.go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;|- go.mod
|- go.sum
|- main.go
|- readme.md
|- models /
   |- book.go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Move the book struct code block into the &lt;code&gt;book.go&lt;/code&gt; file and update the name of the 'book' struct to 'Book' (this makes it visible to other packages and we can import it into other packages). Add the code &lt;code&gt;package models&lt;/code&gt; at the top of the book.go. The file should have the 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;models&lt;/span&gt;

&lt;span class="c"&gt;// book struct represents data about a book record.&lt;/span&gt;
&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Book&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;ID&lt;/span&gt;     &lt;span class="kt"&gt;string&lt;/span&gt;  &lt;span class="s"&gt;`json:"id"`&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;Author&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;  &lt;span class="s"&gt;`json:"author"`&lt;/span&gt;
    &lt;span class="n"&gt;Price&lt;/span&gt;  &lt;span class="kt"&gt;float64&lt;/span&gt; &lt;span class="s"&gt;`json:"price"`&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Update the two book struct references in the &lt;code&gt;main.go&lt;/code&gt; file; the books and &lt;br&gt;
&lt;code&gt;postBook&lt;/code&gt; function as shown below.&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;// books slice to seed record to book store.&lt;/span&gt;
&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;books&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Book&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="c"&gt;// 📌 Update reference&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"A Day in the Life of Abed Salama"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Author&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Nathan Thrall"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;56.99&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"King: A life"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Author&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Jonathan Eig"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;56.99&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Where we go from here"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Author&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Bernie Sanders"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;17.99&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"4"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Buiding a dream server"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Author&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Yiga ue"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;39.99&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"5"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Clean Code "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Author&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Robert C Martin"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;39.99&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;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;postBook&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;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;newBook&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Book&lt;/span&gt; &lt;span class="c"&gt;// 📌 Update reference&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="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BindJSON&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;newBook&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="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;books&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;books&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;newBook&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;IndentedJSON&lt;/span&gt;&lt;span class="p"&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;StatusCreated&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;newBook&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;h2&gt;
  
  
  Database Setup
&lt;/h2&gt;

&lt;p&gt;Set up a database to hold our book records. The database will replace our in-memory slice store.&lt;br&gt;
From the terminal/command prompt, create a new directory &lt;code&gt;database&lt;/code&gt; and add a bookstore.sql file. The instructions for setting up the bookstore database are shown in the SQL file.&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;database
&lt;span class="nb"&gt;touch &lt;/span&gt;database/bookstore.sql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's move the &lt;code&gt;books&lt;/code&gt; collection into this file as a SQL CREATE command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- connect on CLI: mysql -u dbuser -p&lt;/span&gt;
&lt;span class="c1"&gt;-- Enter password:&lt;/span&gt;
&lt;span class="c1"&gt;-- mysql&amp;gt; CREATE DATABASE bookstore;&lt;/span&gt;
&lt;span class="c1"&gt;-- mysql&amp;gt; USE bookstore;&lt;/span&gt;
&lt;span class="c1"&gt;-- mysql&amp;gt; SOURCE /path to/bookstore.sql;&lt;/span&gt;
&lt;span class="c1"&gt;-- mysql&amp;gt; exit (closes connection);&lt;/span&gt;

&lt;span class="k"&gt;DROP&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;IF&lt;/span&gt; &lt;span class="k"&gt;EXISTS&lt;/span&gt; &lt;span class="n"&gt;book&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;book&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;id&lt;/span&gt;         &lt;span class="nb"&gt;INT&lt;/span&gt; &lt;span class="n"&gt;AUTO_INCREMENT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;title&lt;/span&gt;      &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;128&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;author&lt;/span&gt;     &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;price&lt;/span&gt;      &lt;span class="nb"&gt;DECIMAL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;`id`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;book&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;author&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;"A Day in the Life of Abed Salama"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;"Nathan Thrall"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;"King: A life"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;"Jonathan Eig"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;56&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;99&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;"Where we go from here"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;"Bernie Sanders"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;23&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;99&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;"Buiding a dream server"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;"Yiga ue"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;39&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;99&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;"Clean Code "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;"Robert C Martin"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;49&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;99&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Database connection
&lt;/h2&gt;

&lt;p&gt;We need to create a connection to our database programmatically.&lt;br&gt;
Two major dependencies are needed to do that, github.com/joho/godotenv and github.com/go-sql-driver/mysql.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a .env file in the root of the application.&lt;/li&gt;
&lt;li&gt;Add the database connection variables into the .env file as shown.
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DBUSER=root
DBPASS=password # replace with your password
DBHOST=localhost
DBNAME=bookstore # can be any name of your choice
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;In the database directory create a new file name dbconn.go. 
Add the following code in the dbconn.go file.
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;database&lt;/span&gt;
&lt;span class="m"&gt;2&lt;/span&gt;
&lt;span class="m"&gt;3&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="m"&gt;4&lt;/span&gt;   &lt;span class="s"&gt;"database/sql"&lt;/span&gt;
&lt;span class="m"&gt;5&lt;/span&gt;   &lt;span class="s"&gt;"fmt"&lt;/span&gt;
&lt;span class="m"&gt;6&lt;/span&gt;   &lt;span class="s"&gt;"log"&lt;/span&gt;
&lt;span class="m"&gt;7&lt;/span&gt;   &lt;span class="s"&gt;"os"&lt;/span&gt;
&lt;span class="m"&gt;8&lt;/span&gt;   &lt;span class="s"&gt;"github.com/joho/godotenv"&lt;/span&gt;
&lt;span class="m"&gt;9&lt;/span&gt;
&lt;span class="m"&gt;10&lt;/span&gt;  &lt;span class="s"&gt;"github.com/go-sql-driver/mysql"&lt;/span&gt;
&lt;span class="m"&gt;11&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="m"&gt;12&lt;/span&gt;
&lt;span class="m"&gt;13&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;DBConnect&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="m"&gt;14&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="m"&gt;15&lt;/span&gt;
&lt;span class="m"&gt;16&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="m"&gt;17&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;"Some error occured. Err: %s"&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="m"&gt;18&lt;/span&gt;  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="m"&gt;19&lt;/span&gt;
&lt;span class="m"&gt;20&lt;/span&gt;  &lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;mysql&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Config&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="m"&gt;21&lt;/span&gt;    &lt;span class="n"&gt;User&lt;/span&gt;&lt;span class="o"&gt;:&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="s"&gt;"DBUSER"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="m"&gt;22&lt;/span&gt;    &lt;span class="n"&gt;Passwd&lt;/span&gt;&lt;span class="o"&gt;:&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="s"&gt;"DBPASS"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="m"&gt;23&lt;/span&gt;    &lt;span class="n"&gt;Net&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"tcp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="m"&gt;24&lt;/span&gt;    &lt;span class="n"&gt;Addr&lt;/span&gt;&lt;span class="o"&gt;:&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="s"&gt;"DBHOST"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="m"&gt;25&lt;/span&gt;    &lt;span class="n"&gt;DBName&lt;/span&gt;&lt;span class="o"&gt;:&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="s"&gt;"DBNAME"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="m"&gt;26&lt;/span&gt;  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="m"&gt;27&lt;/span&gt;
&lt;span class="m"&gt;28&lt;/span&gt;  &lt;span class="n"&gt;db&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;sql&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"mysql"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FormatDSN&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="m"&gt;29&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="m"&gt;30&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;Fatal&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="m"&gt;31&lt;/span&gt;  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="m"&gt;32&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;db&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Ping&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="m"&gt;33&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="m"&gt;34&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;Fatal&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="m"&gt;35&lt;/span&gt;  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="m"&gt;36&lt;/span&gt;
&lt;span class="m"&gt;37&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;"DB connection successful"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="m"&gt;38&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;On the CLI run the command to import all dependencies.&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 &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;On line 14: &lt;code&gt;godotenv.Load()&lt;/code&gt; provided by github.com/joho/godotenv dependency retrieves the values of our .env file.&lt;/li&gt;
&lt;li&gt;On lines 20 - 26, use the MySQL package struct Config to collect the connection properties from the .env.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On line 28, open the SQL connection passing the driver and the connection string which is in this format "username:password@(127.0.0.1:3306)/dbname". The &lt;code&gt;config.FormatDSN()&lt;/code&gt; formats the config struct into the connection string behind the scene so we don't have to do it manually. Note, there are other &lt;a href="https://go.dev/wiki/SQLDrivers" rel="noopener noreferrer"&gt;drivers&lt;/a&gt; aside from MySQL.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On line 32, test the connection is successful with &lt;code&gt;db.Ping()&lt;/code&gt;.&lt;br&gt;
For a start, if there is any error we end execution with a call to &lt;code&gt;log.Fatal("")&lt;/code&gt; and print the error to the console.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Finally, in the &lt;code&gt;main.go&lt;/code&gt; file there is a call to the  &lt;code&gt;database.DBConnect()&lt;/code&gt; function just below line 35 in the main() function to temporarily test that the connection setup worked. Don't forget to import the     "github.com/yigaue/bookstore/database" package.&lt;br&gt;
Run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go run &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It would help if you got "DB connection successful" response.&lt;br&gt;
Your main function should look like this now.&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;database&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DBConnect&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;router&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Default&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;router&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;"/books"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;getBooks&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;router&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;"/books/:id"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;getBook&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;router&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;POST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/books"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;postBook&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;router&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"localhost:8080"&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;Good job if you got here so far.&lt;/p&gt;

&lt;h2&gt;
  
  
  Update the code to use the database
&lt;/h2&gt;

&lt;p&gt;After the endpoints and database setup, let's update the code to use the database instead of the in-memory slice store.&lt;/p&gt;

&lt;p&gt;There are currently three functions in the &lt;code&gt;main.go&lt;/code&gt; file we need to update.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;getBooks function&lt;/li&gt;
&lt;li&gt;getBook function&lt;/li&gt;
&lt;li&gt;postBook function&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We'll add one more, a deleteBook function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;getBooks function&lt;/strong&gt;&lt;br&gt;
Below is the updated code for the getBooks function.&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="m"&gt;23&lt;/span&gt; &lt;span class="c"&gt;// getBooks responds with the list of all books as JSON&lt;/span&gt;
&lt;span class="m"&gt;24&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;getBooks&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;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="m"&gt;25&lt;/span&gt;  &lt;span class="c"&gt;// var db *sql.DB&lt;/span&gt;
&lt;span class="m"&gt;26&lt;/span&gt;  &lt;span class="n"&gt;db&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;database&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DBConnect&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="m"&gt;27&lt;/span&gt;  &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;books&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Book&lt;/span&gt;
&lt;span class="m"&gt;28&lt;/span&gt;
&lt;span class="m"&gt;29&lt;/span&gt;  &lt;span class="n"&gt;rows&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;db&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"SELECT * FROM book"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="m"&gt;30&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="m"&gt;31&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;Errorf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"getBooks: %v"&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="m"&gt;32&lt;/span&gt;  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="m"&gt;33&lt;/span&gt;
&lt;span class="m"&gt;34&lt;/span&gt;  &lt;span class="k"&gt;defer&lt;/span&gt; &lt;span class="n"&gt;rows&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="m"&gt;35&lt;/span&gt;  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Next&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="m"&gt;36&lt;/span&gt;      &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;book&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Book&lt;/span&gt;
&lt;span class="m"&gt;37&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="n"&gt;rows&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Scan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;book&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;book&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Author&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
&lt;span class="m"&gt;38&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;book&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;book&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Price&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="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="m"&gt;39&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;Errorf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"getBooks: %v"&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="m"&gt;40&lt;/span&gt;      &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="m"&gt;41&lt;/span&gt;
&lt;span class="m"&gt;42&lt;/span&gt;      &lt;span class="n"&gt;books&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;books&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;book&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="m"&gt;43&lt;/span&gt;  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="m"&gt;44&lt;/span&gt;
&lt;span class="m"&gt;45&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="n"&gt;rows&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Err&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="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="m"&gt;46&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;Errorf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"getBooks: %v"&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="m"&gt;47&lt;/span&gt;  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="m"&gt;48&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;IndentedJSON&lt;/span&gt;&lt;span class="p"&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;StatusOK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;books&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="m"&gt;49&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Much has not changed from the previous code except the addition of the SQL query to fetch the books and minor updates.&lt;br&gt;
First, connect to the database on line 26,&lt;br&gt;
&lt;code&gt;DBConnect()&lt;/code&gt; is the function that connects to our DB in the &lt;code&gt;database&lt;/code&gt; package&lt;/p&gt;

&lt;p&gt;A slice of type Book is declared on line 27 imported from the models' package.&lt;/p&gt;

&lt;p&gt;Line 29 - 32 we query the database for all books and check for any error.&lt;/p&gt;

&lt;p&gt;Line 34, &lt;code&gt;rows.Close()&lt;/code&gt; prevents further enumeration of the fetched rows.&lt;/p&gt;

&lt;p&gt;In lines 35 - 43: loop through the rows fetched from the database with &lt;code&gt;rows.Next()&lt;/code&gt;. &lt;code&gt;rows.Next()&lt;/code&gt; returns true if there is a next row and false if none making it possible to use a &lt;code&gt;for loop&lt;/code&gt; on it. Each row is scanned into our book struct with the column of the database copied into the appropriate struct property.&lt;br&gt;
Line 42: append each book struct created from the row columns into the books slice defined on line 27.&lt;br&gt;
Then we return a Json of the &lt;code&gt;books&lt;/code&gt; slice.&lt;br&gt;
&lt;code&gt;fmt.Errorf&lt;/code&gt; is an error formatter handy to log where an error occurred.&lt;/p&gt;

&lt;p&gt;Test the implementation with curl. First, run the go code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go run &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then open a new terminal and run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl localhost:8080/books
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;getBook function&lt;/strong&gt;&lt;br&gt;
This function fetches a single row using the given &lt;code&gt;ID&lt;/code&gt; of the book.&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="m"&gt;50&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;getBook&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;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="m"&gt;51&lt;/span&gt;  &lt;span class="n"&gt;db&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;database&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DBConnect&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="m"&gt;52&lt;/span&gt;  &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&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;Param&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="m"&gt;53&lt;/span&gt;  &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;book&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Book&lt;/span&gt;
&lt;span class="m"&gt;54&lt;/span&gt;
&lt;span class="m"&gt;55&lt;/span&gt;  &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;QueryRow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"SELECT * FROM book WHERE id = ?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="m"&gt;56&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;row&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Scan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;book&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;book&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Author&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;book&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
   &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;book&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="m"&gt;57&lt;/span&gt;
&lt;span class="m"&gt;58&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="n"&gt;sql&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ErrNoRows&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="m"&gt;59&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;IndentedJSON&lt;/span&gt;&lt;span class="p"&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;StatusNotFound&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
   &lt;span class="n"&gt;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;H&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"message"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"book not found"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="m"&gt;60&lt;/span&gt;  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="m"&gt;61&lt;/span&gt;
&lt;span class="m"&gt;62&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="m"&gt;63&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;Errorf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"book ID, %d: %v"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;id&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="m"&gt;64&lt;/span&gt;  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="m"&gt;65&lt;/span&gt;
&lt;span class="m"&gt;66&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;IndentedJSON&lt;/span&gt;&lt;span class="p"&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;StatusOK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;book&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="m"&gt;67&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Again, connect to the database.&lt;br&gt;
On line 51 we get the id of the book.&lt;/p&gt;

&lt;p&gt;On line 55: use &lt;code&gt;db.QueryRow&lt;/code&gt; to get a single row. Note it’s different from &lt;code&gt;db.Query&lt;/code&gt; method which returns multiple rows.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;row.Scan&lt;/code&gt; method copies the columns of the row to the appropriate book &lt;code&gt;struct&lt;/code&gt; fields.&lt;/p&gt;

&lt;p&gt;Sql.ErrNoRows is returned by &lt;code&gt;row.Scan&lt;/code&gt; method when no result is returned by &lt;code&gt;db.QueryRow&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;On lines 62 - 64, we check for any error.&lt;/p&gt;

&lt;p&gt;Finally, return the book as JSON.&lt;/p&gt;

&lt;p&gt;Test the implementation with curl. First, run the go code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go run &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then open a new terminal and run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl localhost:8080/books/1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;postBook function&lt;/strong&gt;&lt;br&gt;
Let's update the postBook function.&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="m"&gt;69&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;postBook&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;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="m"&gt;70&lt;/span&gt;  &lt;span class="n"&gt;db&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;database&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DBConnect&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="m"&gt;71&lt;/span&gt;  &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;newBook&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Book&lt;/span&gt;
&lt;span class="m"&gt;72&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="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BindJSON&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;newBook&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="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="m"&gt;73&lt;/span&gt;      &lt;span class="k"&gt;return&lt;/span&gt;
&lt;span class="m"&gt;74&lt;/span&gt;  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="m"&gt;75&lt;/span&gt;  &lt;span class="n"&gt;row&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;db&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Exec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"INSERT INTO book (title, author, price) VALUES (?, ?, ?)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;newBook&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;newBook&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Author&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;newBook&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="m"&gt;76&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="m"&gt;77&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;Errorf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"postBook %v"&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="m"&gt;78&lt;/span&gt;  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="m"&gt;79&lt;/span&gt;
&lt;span class="m"&gt;80&lt;/span&gt;  &lt;span class="n"&gt;id&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;row&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LastInsertId&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="m"&gt;81&lt;/span&gt;
&lt;span class="m"&gt;82&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="m"&gt;83&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;Errorf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"error getting lastID: %v"&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="m"&gt;84&lt;/span&gt;  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="m"&gt;85&lt;/span&gt;
&lt;span class="m"&gt;86&lt;/span&gt;  &lt;span class="n"&gt;newBook&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;strconv&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Itoa&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="m"&gt;87&lt;/span&gt;
&lt;span class="m"&gt;88&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;IndentedJSON&lt;/span&gt;&lt;span class="p"&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;StatusCreated&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;newBook&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="m"&gt;89&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First, connect to the database.&lt;/p&gt;

&lt;p&gt;Line 72, we get the request body JSON, bind it to the book struct fields and check for error at the same time.&lt;/p&gt;

&lt;p&gt;Lines 75 -78: execute the &lt;code&gt;INSERT&lt;/code&gt; SQL query to add the book to the database table.&lt;/p&gt;

&lt;p&gt;Line 80, we get the ID of the recently inserted row and then assign this ID to the book struct ID field.&lt;br&gt;
The int64 ID returned from &lt;code&gt;row.LastInsertedId()&lt;/code&gt; is converted to a string on line 86 using &lt;code&gt;strconv.Itoa&lt;/code&gt; (int to ASCII).&lt;br&gt;
Note &lt;code&gt;strconv.Itoa()&lt;/code&gt; takes an int type so the ID is first converted from int64 to int.&lt;br&gt;
On line 88, return the book JSON with the status code of 201(http.StatusCreated&lt;br&gt;
)&lt;/p&gt;

&lt;p&gt;Test the implementation by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go run &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then open another terminal tab and run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl http://localhost:8080/books &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--include&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--header&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--request&lt;/span&gt; &lt;span class="s2"&gt;"POST"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--data&lt;/span&gt; &lt;span class="s1"&gt;'{"title": "Things fall apart", "author": "Chinua Achebe", "price": 30.90}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;deleteBook function&lt;/strong&gt;&lt;br&gt;
The deleteBook function was not part of the first &lt;a href="https://dev.to/goslek/a-beginner-friendly-approach-to-developing-a-rest-api-with-go-and-gin-301p"&gt;tutorial&lt;/a&gt;.&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="m"&gt;91&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;deleteBook&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;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="m"&gt;92&lt;/span&gt;  &lt;span class="n"&gt;db&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;database&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DBConnect&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="m"&gt;93&lt;/span&gt;  &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&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;Param&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="m"&gt;94&lt;/span&gt;  &lt;span class="n"&gt;_&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;db&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Exec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"DELETE FROM book WHERE id = ?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="m"&gt;95&lt;/span&gt;
&lt;span class="m"&gt;96&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="m"&gt;97&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;Errorf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"deleteBook %v"&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="m"&gt;98&lt;/span&gt;  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="m"&gt;100&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;IndentedJSON&lt;/span&gt;&lt;span class="p"&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;StatusOK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Book deleted successfully"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="m"&gt;101&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this code, connect to the database, get the ID of the book to be deleted, and then execute the &lt;code&gt;DELETE&lt;/code&gt; SQL query. Finally, a response is returned. This function can be improved to check for errors if the book is not found and others.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This tutorial focused on interacting with our database using Go's built-in packages and the gin framework for routing, reducing the distraction of learning the intended core concepts.&lt;br&gt;
In the next tutorial, we'll add more functionality and JWT authentication. I hope you enjoyed coding along. Do well to leave questions and feedback in the comment section.&lt;/p&gt;

&lt;p&gt;See the complete code on &lt;a href="https://github.com/Yigaue/bookstore/tree/database-storage" rel="noopener noreferrer"&gt;Github&lt;/a&gt;. Feel free to contribute or open an issue.&lt;/p&gt;

</description>
      <category>go</category>
      <category>gin</category>
      <category>mysql</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Why I Built a Vscode Extension</title>
      <dc:creator>Gospel Lekia</dc:creator>
      <pubDate>Fri, 12 Jan 2024 00:40:11 +0000</pubDate>
      <link>https://dev.to/goslek/why-i-built-a-vscode-extension-430h</link>
      <guid>https://dev.to/goslek/why-i-built-a-vscode-extension-430h</guid>
      <description>&lt;p&gt;A couple of times, we spend time tweaking VScode themes. It could be fun but sometimes tiring and time-consuming. I have travelled this road many times but went a little over the board this time, and why would I do that?&lt;/p&gt;

&lt;h2&gt;
  
  
  The need for a suitable theme
&lt;/h2&gt;

&lt;p&gt;I have enjoyed using wonderful themes, from Material Theme to Monokai. I always wanted to change something in every theme, especially the colours to resonate with me and the comfort of my eyes.&lt;/p&gt;

&lt;h2&gt;
  
  
  A little adventure wouldn't hurt
&lt;/h2&gt;

&lt;p&gt;During the close of the year, 2023 I decided to do something a little different from my usual development. I considered doing some design tasks, colour combinations and colour effects. It was nice to put it into practice. So boom, I built and published my Vscode theme extension.&lt;/p&gt;

&lt;h2&gt;
  
  
  The need to give back to the community
&lt;/h2&gt;

&lt;p&gt;The tech community has always been awesome in open-source and sacrificial endeavours. Almost everyone has it in mind to give back to this wonderful community of love.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final note
&lt;/h2&gt;

&lt;p&gt;I enjoyed designing the theme. Some other time I will write about the process.&lt;br&gt;
Thanks for reading and I hope you enjoyed this episode 🙂. To install on Vscode, search for &lt;code&gt;Dukana&lt;/code&gt;.&lt;br&gt;
Or check the &lt;a href="https://marketplace.visualstudio.com/items?itemName=lekiagospel.dukana&amp;amp;ssr=false#overview" rel="noopener noreferrer"&gt;marketplace&lt;/a&gt;. &lt;br&gt;
Be kind to support my endeavours.&lt;/p&gt;

</description>
      <category>vscode</category>
      <category>tools</category>
      <category>ui</category>
      <category>design</category>
    </item>
    <item>
      <title>A One-Pager to Understanding Pointers in Go (expanded)</title>
      <dc:creator>Gospel Lekia</dc:creator>
      <pubDate>Tue, 02 Jan 2024 00:48:14 +0000</pubDate>
      <link>https://dev.to/goslek/a-one-pager-to-understanding-pointers-in-go-expanded-52m4</link>
      <guid>https://dev.to/goslek/a-one-pager-to-understanding-pointers-in-go-expanded-52m4</guid>
      <description>&lt;p&gt;Scared of pointers let’s end the fear once and for all.&lt;/p&gt;

&lt;p&gt;Pointers are a powerful feature in programming languages that allow you to work with memory addresses directly. In the Go programming language, pointers work similarly to other C-style languages, but with some differences in syntax and behaviour.&lt;/p&gt;

&lt;p&gt;To understand pointers, you'll need to clearly understand the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;variable&lt;/li&gt;
&lt;li&gt;value&lt;/li&gt;
&lt;li&gt;type&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's define them in one statement: &lt;code&gt;topic := "go programming"&lt;/code&gt;.&lt;br&gt;
The variable is &lt;code&gt;topic&lt;/code&gt;, the value is "go programming" and the type is a string. There is one more thing that is not obvious on the list and that's the memory address of the variable. Every variable has an address in memory and that's where pointers come in.&lt;/p&gt;

&lt;p&gt;A variable does not only hold a value but also has an address. This is a hot fact to keep in mind. Consider it like a house. It has an address and can contain a person assuming one person per house.&lt;br&gt;
Say Mr John Doe's house address is 100 ABC Street, Omo Island, Dukana. It means if we get to the above address we'll find Mr John.&lt;/p&gt;

&lt;p&gt;Type is important in Go just like other languages. Every value in Go is of a type. For instance, 4, 9, and 5 can be called integer types, 5.0, and 4.4 float64 types, "welcome", and "tomorrow" string types and more. If a variable holds a value of a type then that variable is of that type.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;age := 30&lt;/code&gt; &lt;br&gt;
Variable, age here is an integer type since it holds an integer value.&lt;br&gt;
There is also a pointer type just like every other type mentioned above. &lt;br&gt;
Every variable has a location in memory (more like an address). &lt;br&gt;
Let's say the address of a variable, &lt;code&gt;b&lt;/code&gt; in memory is 0xc000012028 (yes, memory addresses look like this). We can assign the value to another variable like so &lt;code&gt;u := 0xc000012028&lt;/code&gt; (note, this is an illustration). In this case &lt;code&gt;u&lt;/code&gt; is a pointer (to &lt;code&gt;b&lt;/code&gt;).&lt;/p&gt;
&lt;h3&gt;
  
  
  Exercise:
&lt;/h3&gt;

&lt;p&gt;Mention the variable types in the examples.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;name := "John Doe" // name is string type&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;age := 30 // age is integer type&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;height := 1.7  // height is float64 type&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;pToName := &amp;amp;name  // ptoName is a pointer type; '&amp;amp;name' is the memory address of name&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  What is a Pointer in Go?
&lt;/h2&gt;

&lt;p&gt;A pointer holds the memory address of a value or from the angle of a variable, a pointer is a variable that holds the memory address of another variable.&lt;/p&gt;

&lt;p&gt;A pointer is represented by the &lt;code&gt;*&lt;/code&gt; symbol followed by the type of variable it points to. For example, the following code declares a pointer to an integer variable:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;var p *int&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In Go you declare a variable like this &lt;code&gt;var age int&lt;/code&gt; but if age is a pointer you will declare it like this instead &lt;code&gt;var age *int&lt;/code&gt;. This is not the same as dereferencing (defined below).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here, p is a pointer to an integer variable. It's important to note that p is currently a nil pointer, meaning it doesn't point to any valid memory address as it's just a declaration.&lt;/p&gt;
&lt;h2&gt;
  
  
  Creating a Pointer
&lt;/h2&gt;

&lt;p&gt;To create a pointer to a variable, you use the &lt;code&gt;&amp;amp;&lt;/code&gt; operator followed by the variable's name. For example, the following code declares an integer variable x and creates a pointer p that points to it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x := 42
p := &amp;amp;x // p points to x
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, &lt;code&gt;p&lt;/code&gt; points to the memory address of &lt;code&gt;x&lt;/code&gt;, which is the address where the value 42 is stored.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dereferencing a Pointer
&lt;/h2&gt;

&lt;p&gt;There is a relationship between pointers and values.&lt;br&gt;
Given an address, we can get the value at the location and vice-versa.&lt;/p&gt;

&lt;p&gt;To access the value at the memory address, you use the * operator followed by the pointer variable name. This operation is called dereferencing the pointer. For example, the following code dereferences the pointer p and assigns the value 100 to the variable it points to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*p = 100
// We're setting x to 100 through p.
// Now, if we print the value of x, it will be 100:
// x was initially 42 (defined above).

fmt.Println(x) // Output: 100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that you can only dereference a non-nil pointer. If you try to dereference a nil pointer, your program will crash with a runtime error.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two Ways to Use the &lt;code&gt;*&lt;/code&gt; Symbol
&lt;/h2&gt;

&lt;p&gt;To clear a common confusion around &lt;code&gt;*&lt;/code&gt;, it's good to know we can use it in two different ways.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;To indicate that a variable is a pointer in variable declaration.&lt;/li&gt;
&lt;li&gt;To deference a pointer variable.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The syntax examples in the first case: &lt;code&gt;var age *int&lt;/code&gt;, &lt;code&gt;var name *string&lt;/code&gt;. The &lt;code&gt;*&lt;/code&gt; is followed by the type.&lt;br&gt;
In the second case, the &lt;code&gt;*&lt;/code&gt; is followed by a variable like so: &lt;code&gt;*name&lt;/code&gt;, &lt;code&gt;*age&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Passing Pointers to Functions
&lt;/h2&gt;

&lt;p&gt;Normally, when a variable is passed to a function it's passed as a copy.&lt;br&gt;
Modifying the variable in the function does not modify the one outside the function.&lt;br&gt;
But if we want to modify the variable outside the function within the function we can pass it as reference using a pointer. &lt;/p&gt;

&lt;p&gt;One common use of pointers is to pass a variable to a function by reference, allowing the function to modify the variable directly. To do this in Go, you simply pass the pointer to the function. For example, the following code declares a function that takes a pointer to an integer variable and increments its value:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;func increment(p *int) {
    *p++
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To call this function and increment the value of x defined earlier, you pass the pointer to x as an argument:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;increment(&amp;amp;x)
fmt.Println(x) // Output: 101
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, &lt;code&gt;increment(&amp;amp;x)&lt;/code&gt; takes a pointer to x, which dereferences it and increments the value it points to.&lt;/p&gt;

&lt;h3&gt;
  
  
  Further Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import "fmt"

func main() {
    age := 8      // declare a variable and assign a value to it.
    printAge(age) // we pass a copy of the variable to the function.
    // OUTPUT:
    // AGE in function: 10
    // memory location in function: 0xc000012040

    fmt.Println("AGE in global:", age)
    fmt.Println("memory location of age in global:", &amp;amp;age)
    // OUTPUT:
    // AGE in global: 8
    // memory location of age in global: 0xc000012028

    printAgePointerParameter(&amp;amp;age)
    fmt.Println("AGE in global after pointer function:", age)
    // OUTPUT:
    // memory location in pointer function: 0xc000012028
    // value in memory location in pointer function: 8
    // age in pointer function after reasignment: 20
    // AGE in global after pointer function: 20 (the original variable is affected after it's changed in the pointer function)

}

func printAge(age int) {
    age = 10 // reasign a value to the variable
    fmt.Println("AGE in function:", age)
    fmt.Println("memory location in function:", &amp;amp;age)
}

func printAgePointerParameter(age *int) { // function takes a pointer type of int
    fmt.Println("memory location in pointer function:", age)
    fmt.Println("value in memory location in pointer function:", *age) // we deference the pointer and print it.
    *age = 20 // we deference the variable and reasign a new value to it. This also affects the original variable.

    fmt.Println("age in pointer function after reasignment:", *age)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://go.dev/play/p/gkR4S8u9hdC" rel="noopener noreferrer"&gt;Run code in playground &lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits of pointers
&lt;/h2&gt;

&lt;p&gt;Dynamic Memory Allocation: Pointers are often used to allocate and manage memory dynamically in Go programs. This allows you to allocate memory for data structures at runtime, rather than relying on compile-time allocation. For example, you can use pointers to create linked lists, trees, and other dynamic data structures.&lt;/p&gt;

&lt;p&gt;Sharing Data between Functions: Pointers can be used to share data between functions and avoid creating copies of large data structures. By passing a pointer to a function, you can allow the function to modify the original data structure directly, rather than creating a new copy of it.&lt;br&gt;
Performance Optimization: Pointers can be used to optimize performance in certain situations, such as when working with large data sets or in high-performance computing applications. By working directly with memory addresses, you can avoid unnecessary memory copies and improve the efficiency of your program.&lt;br&gt;
Interfacing with C Libraries: Go programs can interface with C libraries using pointers, which are a common feature in C programming. This allows you to take advantage of existing C libraries and leverage their functionality in your Go programs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Pointers are a powerful tool in the Go programming language that allows you to work with memory addresses directly. They can be used to pass variables by 'reference' to functions, modify values directly, and work with complex data structures. However, it’s important to use pointers with care and avoid common pitfalls such as dereferencing nil pointers or using dangling pointers that point to invalid memory addresses.&lt;/p&gt;

&lt;p&gt;Here is my personal Github gist(note) that inspires this article. Feel free to leave comments. &lt;a href="https://gist.github.com/Yigaue/d0a0128a86914ef718ed48457d003031" rel="noopener noreferrer"&gt;https://gist.github.com/Yigaue/d0a0128a86914ef718ed48457d003031&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Other Useful Resources
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/Yigaue/GOQuickDive" rel="noopener noreferrer"&gt;Go Curated learning resources&lt;/a&gt;&lt;br&gt;
&lt;a href="https://go.dev/ref/spec#Address_operators" rel="noopener noreferrer"&gt;Go Address Operators (Go doc)&lt;/a&gt;&lt;br&gt;
&lt;a href="https://go.dev/ref/spec#Pointer_types" rel="noopener noreferrer"&gt;Pointer Types Operators (Go doc)&lt;/a&gt;&lt;br&gt;
&lt;a href="https://go.dev/tour/moretypes/4" rel="noopener noreferrer"&gt;Pointers to a struct (Playground)&lt;/a&gt;&lt;br&gt;
&lt;a href="https://go.dev/tour/moretypes/1" rel="noopener noreferrer"&gt;Pointers (playground)&lt;/a&gt;&lt;/p&gt;

</description>
      <category>go</category>
      <category>tutorial</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>A Beginner-friendly Approach to Developing a REST API with Go and Gin</title>
      <dc:creator>Gospel Lekia</dc:creator>
      <pubDate>Sun, 24 Dec 2023 22:16:00 +0000</pubDate>
      <link>https://dev.to/goslek/a-beginner-friendly-approach-to-developing-a-rest-api-with-go-and-gin-301p</link>
      <guid>https://dev.to/goslek/a-beginner-friendly-approach-to-developing-a-rest-api-with-go-and-gin-301p</guid>
      <description>&lt;p&gt;We learn to learn again (until we come to an "Aha!" moment if we're lucky enough). Let's get to the heart of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Definitons
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.wikiwand.com/en/Go_(programming_language)" rel="noopener noreferrer"&gt;&lt;strong&gt;Go&lt;/strong&gt;&lt;/a&gt; is a statically typed, compiled high-level programming language designed at Google. It's a modern programming language well-positioned for the evolving technology needs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://gin-gonic.com/docs/" rel="noopener noreferrer"&gt;Gin&lt;/a&gt;&lt;/strong&gt; is a web framework written in Go that simplifies building web applications.&lt;/p&gt;

&lt;p&gt;Fully functional REST APIs can be developed with Go native packages. However, there are tools created to increase efficiency and reduce development time, and very likely you will be working more with frameworks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisite
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Basic understanding of REST&lt;/li&gt;
&lt;li&gt;Introductory knowledge of Go&lt;/li&gt;
&lt;li&gt;Introductory knowledge of Gin (optional)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tools
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A computer, laptop or anything similar.&lt;/li&gt;
&lt;li&gt;Go install and set up. &lt;a href="https://go.dev/doc/install" rel="noopener noreferrer"&gt;Installation instruction&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;Any code editor or IDE of choice e.g. &lt;a href="https://code.visualstudio.com/download" rel="noopener noreferrer"&gt;Vscode&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;A command terminal, cmd or PowerShell (windows)&lt;/li&gt;
&lt;li&gt;Curl or any API client e.g Postman&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://git-scm.com/downloads" rel="noopener noreferrer"&gt;Git&lt;/a&gt; for version control (optional)&lt;/li&gt;
&lt;li&gt;A repository to store your code (optional)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  In this tutorial:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Design API endpoints&lt;/li&gt;
&lt;li&gt;Setup project structure&lt;/li&gt;
&lt;li&gt;Create the data store&lt;/li&gt;
&lt;li&gt;Write the corresponding endpoint handlers:

&lt;ul&gt;
&lt;li&gt;Handler to return all books&lt;/li&gt;
&lt;li&gt;Handler to add a new book to the data store&lt;/li&gt;
&lt;li&gt;Handler to return a specific book&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Associate Handles to Request Endpoints&lt;/li&gt;

&lt;li&gt;Conclusion&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  What We will be building
&lt;/h2&gt;

&lt;p&gt;A simple bookstore service where books can be added and retrieved.&lt;/p&gt;

&lt;h2&gt;
  
  
  Design API endpoints
&lt;/h2&gt;

&lt;p&gt;API design typically starts with writing out the endpoints. We'll have endpoints to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Retrieve all books in the store: &lt;/li&gt;
&lt;li&gt;Retrieve a particular book from the store using the book Id&lt;/li&gt;
&lt;li&gt;Add a book to the store.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;em&gt;&lt;code&gt;/books&lt;/code&gt;&lt;/em&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;GET - return a list of all books as JSON.&lt;/li&gt;
&lt;li&gt;POST - add a new book resource from a JSON request.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;em&gt;&lt;code&gt;/books/:id&lt;/code&gt;&lt;/em&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;GET - retrieve a book by using the ID, returned as JSON.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For simplicity, there are things we did not consider in designing these API endpoints.&lt;br&gt;
In this tutorial, we'll not consider API versioning, middleware, authentication, database etc. Those will be coming in future tutorials as a continuation of this.&lt;/p&gt;
&lt;h2&gt;
  
  
  Set up Project Structure
&lt;/h2&gt;

&lt;p&gt;Using any editor of choice create a directory to hold your project, and name the directory bookstore.&lt;br&gt;
Or from your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd ~
mkdir bookstore
cd bookstore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every programming language has a way of managing packages and dependencies. In Go, dependency is managed using Go module.&lt;/p&gt;

&lt;p&gt;So let's create a module to manage/track dependencies similar to npm init using our terminal.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go mod init github.com/yigaue/bookstore
go: creating new go.mod: module github.com/yigaue/bookstore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can use any path of your choice. It's perfectly fine. However, it's common to see developers append the project name to their GitHub username like above, in that way, it's easy to publish their code as a package and reuse it in other code.&lt;br&gt;
Without using Github we can simply do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go mod init project/bookstore
go: creating new go.mod: module project/bookstore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can see that a file, &lt;code&gt;go.mod&lt;/code&gt; is created. Quickly view the content with or open from the editor:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat go.mod
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This file contains the module path: the import path prefix for all packages within the module.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create Data Store
&lt;/h2&gt;

&lt;p&gt;For simplicity, we'll store our data in memory. A typical API will store data in a database. For this, we'll use struct and slice. Do not worry if slice and struct are not familiar, you can read more about them.&lt;br&gt;
The data in memory is not persistent, which means the data is lost every time we stop and start our local server.&lt;/p&gt;

&lt;p&gt;Create a main.go file in the project directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch main.go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the following code to the main.go file.&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="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"net/http"&lt;/span&gt;
    &lt;span class="s"&gt;"github.com/gin-gonic/gin"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c"&gt;// book struct defines a book similar to an object&lt;/span&gt;
&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;book&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;ID&lt;/span&gt;     &lt;span class="kt"&gt;string&lt;/span&gt;  &lt;span class="s"&gt;`json:"id"`&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;Author&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;  &lt;span class="s"&gt;`json:"author"`&lt;/span&gt;
    &lt;span class="n"&gt;Price&lt;/span&gt;  &lt;span class="kt"&gt;float64&lt;/span&gt; &lt;span class="s"&gt;`json:"price"`&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;books&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="n"&gt;book&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"A Day in the Life of Abed Salama"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Author&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Nathan Thrall"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;56.99&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"King: A life"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Author&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Jonathan Eig"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;56.99&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Where we go from here"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Author&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Ken Wiwa"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;17.99&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"4"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Buiding a dream server"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Author&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Lekia Yiga"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;39.99&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"5"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Clean Code "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Author&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Robert C Martin"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;39.99&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;Explanation: The first line is our package declaration. &lt;code&gt;package main&lt;/code&gt; is required for an executable standalone program. A package is similar to a namespace. Run the command to fetch all dependencies in the &lt;code&gt;import&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;go get .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All dependencies in the import statement will be fetched and a &lt;code&gt;sum.go&lt;/code&gt; file will be created to lock our dependencies, similar to package-lock.json.&lt;/p&gt;

&lt;p&gt;Below the package declaration is the &lt;code&gt;import&lt;/code&gt; of needed dependencies.&lt;br&gt;
The book &lt;code&gt;struct&lt;/code&gt; defines the structure of a book like a book object. When a book is created it follows the blueprint of the book &lt;code&gt;struct&lt;/code&gt;. A book will have a title, author, ISBN, and price amongst others. Note that we have added a &lt;code&gt;struct&lt;/code&gt; tag like &lt;code&gt;json:"title"&lt;/code&gt;. This will ensure that the JSON key returned is formatted as specified and does not use the struct keys like "Title".&lt;/p&gt;

&lt;p&gt;Beneath the book definition is the book store: a &lt;code&gt;slice&lt;/code&gt; of books. Five books have been added to the collection as samples. A &lt;code&gt;slice&lt;/code&gt; in Go is similar to an array but more flexible. We can easily manipulate the slice, adding and removing items.&lt;/p&gt;
&lt;h2&gt;
  
  
  Write the Corresponding Endpoint Handlers
&lt;/h2&gt;

&lt;p&gt;What we want to do here is map the request path to the appropriate handler(a portion of code that executes the logic associated with that request path).&lt;/p&gt;
&lt;h3&gt;
  
  
  Handler to return all books
&lt;/h3&gt;

&lt;p&gt;GET: &lt;code&gt;/books&lt;/code&gt; - call the getBooks handler when a user visits the &lt;code&gt;/books&lt;/code&gt; endpoint. Add the function below to the existing code. The function takes the &lt;code&gt;gin.Context&lt;/code&gt; as a parameter. Recall the &lt;code&gt;gin&lt;/code&gt; package is imported at the beginning of this file.&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;getBooks&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;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;)&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;IndentedJSON&lt;/span&gt;&lt;span class="p"&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;StatusOK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;books&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;code&gt;IndentedJSON&lt;/code&gt; serializes the book struct to JSON and the response is returned to the client. The response code &lt;code&gt;http.StatusOk&lt;/code&gt; is the first parameter of IndentedJSON, a constant with a value of 200.&lt;/p&gt;

&lt;h3&gt;
  
  
  Handler to add a new book to the data store
&lt;/h3&gt;

&lt;p&gt;When a post request is made to &lt;code&gt;/books/&lt;/code&gt; we want to add a new book. Let's implement the handler to handle this logic.&lt;/p&gt;

&lt;p&gt;Add the following function to the existing 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;postBook&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;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;newBook&lt;/span&gt; &lt;span class="n"&gt;book&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="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BindJSON&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;newBook&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="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;books&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;books&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;newBook&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;IndentedJSON&lt;/span&gt;&lt;span class="p"&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;StatusCreated&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;newBook&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;The &lt;code&gt;postBook&lt;/code&gt; function takes a &lt;code&gt;gin.Context&lt;/code&gt; parameter. A &lt;code&gt;newBook&lt;/code&gt; variable is declared in the function which is of type &lt;code&gt;book&lt;/code&gt; with underlining type as &lt;code&gt;struct&lt;/code&gt; (declared above). The request body JSON is bound to the &lt;code&gt;newBook&lt;/code&gt; variable with &lt;code&gt;BindJSON(...&lt;/code&gt;. If an error occurs, we exit. &lt;code&gt;append(books, newBook)&lt;/code&gt; appends the &lt;code&gt;newBook&lt;/code&gt; variable to the existing &lt;code&gt;books&lt;/code&gt; slice(data store). Finally, &lt;code&gt;c.IndentedJSON(http.StatusCreated, newBook)&lt;/code&gt; returns the resulting book JSON to the client making the request.&lt;/p&gt;

&lt;h3&gt;
  
  
  Handler to return a specific book
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;/books/:id&lt;/code&gt; endpoint GET method retrieves a book. The handler function is thus:&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;getBook&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;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&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;Param&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;book&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;range&lt;/span&gt; &lt;span class="n"&gt;books&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;book&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;id&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;IndentedJSON&lt;/span&gt;&lt;span class="p"&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;StatusOK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;book&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt;
        &lt;span class="p"&gt;}&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;IndentedJSON&lt;/span&gt;&lt;span class="p"&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;StatusNotFound&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;H&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"message"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; 
 &lt;span class="s"&gt;"book not found"&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;Let's go through what the function is doing.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;gin.Context&lt;/code&gt; is passed as a parameter to the &lt;code&gt;getBook&lt;/code&gt; function. &lt;code&gt;c.Param("id")&lt;/code&gt; retrieves the URL path variable, "id". We loop over the book structs in the slice to find a struct whose ID field matches the id parameter from the URL path. If there is a match we serialize the matching book struct to JSON using &lt;code&gt;c.IndentedJSON...&lt;/code&gt; and return it with an &lt;code&gt;http.statusOk&lt;/code&gt; response. If there is no match StatusNotFound response is returned.&lt;/p&gt;

&lt;h2&gt;
  
  
  Associate Handles to Request Endpoints
&lt;/h2&gt;

&lt;p&gt;Now that the Handlers and the endpoint are defined, Let's map the Handlers to the request endpoints.&lt;/p&gt;

&lt;p&gt;create a function name main like so.&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;router&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Default&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;router&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;"/books"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;getBooks&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;router&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;"/books/:id"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;getBook&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;router&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;POST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/books"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;postBook&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;router&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"localhost:8080"&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;In the &lt;code&gt;main&lt;/code&gt; function we initialize a gin router using &lt;code&gt;gin.Default()&lt;/code&gt;, then associate individual endpoints to the corresponding Handlers we already defined.&lt;/p&gt;

&lt;p&gt;Format your code nicely using &lt;code&gt;go fmt&lt;/code&gt; from the terminal.&lt;br&gt;
Start the server and run the code with the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go run .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see a result similar to &lt;code&gt;GIN-debug] Listening and serving HTTP on localhost:8080&lt;/code&gt; in your terminal.&lt;br&gt;
Open a new terminal and run the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl http://localhost:8080/books
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or use Postman or any API client of choice.&lt;/p&gt;

&lt;p&gt;Result:&lt;br&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%2F3kt5l0y3l653prnu1q5c.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%2F3kt5l0y3l653prnu1q5c.png" alt="Get all books resource image result" width="800" height="813"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Do the same for the other endpoints.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl http://localhost:8080/books/2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result:&lt;br&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%2Fzlb1o7kwhi53hayw9f9l.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%2Fzlb1o7kwhi53hayw9f9l.png" alt="Get a book image image result" width="800" height="447"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl http://localhost:8080/books \
    --include \
    --header "Content-Type: application/json" \
    --request "POST" \
    --data '{"id": "6", "title": "Things fall apart","author": "Chinua Achebe", "price": 30.90}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result:&lt;br&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%2Febi9jd1gopf16g3qg8ts.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%2Febi9jd1gopf16g3qg8ts.png" alt="Add a new book resource image result" width="800" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After adding a book you can verify with the &lt;code&gt;/books&lt;/code&gt; endpoint that the new book was added.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this tutorial, we were able to show a simple implementation of REST API using the Gin framework. Certain considerations were not taken in the implementation. You may have noticed that our data store (Book slice) can hold many non-unique records. That's to say we can have books with the same IDs.&lt;br&gt;
In the coming tutorial, we'll swap our in-memory store with an actual database.&lt;/p&gt;

&lt;p&gt;You can find the full code here on &lt;a href="https://github.com/Yigaue/bookstore" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;br&gt;
Feel free to create an &lt;code&gt;issue&lt;/code&gt; or raise a pull request if you find an issue.&lt;/p&gt;

</description>
      <category>go</category>
      <category>beginners</category>
      <category>rest</category>
      <category>gin</category>
    </item>
    <item>
      <title>3D book: Open and close pages</title>
      <dc:creator>Gospel Lekia</dc:creator>
      <pubDate>Mon, 20 Jun 2022 00:13:30 +0000</pubDate>
      <link>https://dev.to/goslek/3d-book-open-and-close-pages-3pom</link>
      <guid>https://dev.to/goslek/3d-book-open-and-close-pages-3pom</guid>
      <description>&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/lekiaanonim/embed/yLvrKKN?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>codepen</category>
    </item>
    <item>
      <title>Making Sense of Computer Programming/ Web Development</title>
      <dc:creator>Gospel Lekia</dc:creator>
      <pubDate>Sat, 09 Nov 2019 15:12:33 +0000</pubDate>
      <link>https://dev.to/goslek/making-sense-of-computer-programming-web-development-koh</link>
      <guid>https://dev.to/goslek/making-sense-of-computer-programming-web-development-koh</guid>
      <description>&lt;p&gt;Programming/Web development can be tedious. Most time there is a strong feeling of throwing everything away and turning your back on it. But that is not all. One thing that constantly comes to mind is ‘How do I make sense of this’? It becomes discomfort, especially in a fast-paced industry. And then there is a second thought that this is just all you’ve got left and you need to make the most out of it. . . But how?&lt;br&gt;
This article is the first of the series "Making Sense of Computer Programming/ Web Development".&lt;br&gt;
More articles in this series will be posted regularly. We’ll talk about those peculiar, silent questions in the heart of many developers, especially those who think more about a fulfilling life. If you’ve found yourself here, then you’re not alone.&lt;br&gt;
Some programmers/developers came into programming with no background in computer science or its related field. Ya, many are ‘self-taught’. This is not bad in itself as the industry is open to contributions from anyone who can make a difference.&lt;br&gt;
Now, the question is where do I start if I am interested in programming or web development? How do I make sense of web development/programming?&lt;br&gt;
You should understand that when we speak of web development, we are pointing to three key things.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The computer&lt;/li&gt;
&lt;li&gt;The computer language&lt;/li&gt;
&lt;li&gt;The computer User&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These three things should be properly defined and understood and how they relate.&lt;br&gt;
Let’s consider them one after the other.&lt;/p&gt;

&lt;h3&gt;
  
  
  Computers:
&lt;/h3&gt;

&lt;p&gt;Computers affect every part of our lives: from medicine, travel, finance, engineering, socialization, travel, communication, you name it. The list goes on. Such great influence is one that perhaps we didn’t see coming. And what's more, its web spins even deeper into the twenty-first century.&lt;br&gt;
considering these, as a web developer/programmer what does a computer mean to you, and how does it affect you?&lt;br&gt;
Also, how do you as a developer use the computer to affect people and society?&lt;br&gt;
Everyone interacts with a computer differently; the banker, the statistician, the engineer, and you as a developer/programmer. So as a developer, you must understand how you interact with the computer. This is the first thing to understand because everything you do surrounds the computer. The computer is the centre — the computer language, the computer code, and the computer user all point to one thing — the computer.&lt;br&gt;
As a developer, first understand the basics of the computer (computer science), not necessarily the whole thing but the basics. The basics of anything are the foundation of it, no matter how simple it may seem, don’t ignore it. Time spent learning the basics may seem a waste, but that is not the case. In any big building, more time is spent on the foundation than any other part, and the foundation is less visible and admired. You may be tempted to jump to higher things: the seemingly trending things, but don’t. The basics are mostly things that cut across all computer languages and no matter the trends or changes they remain. In this way, you can keep pace with the constant changes in technology without getting blown away. Those who make an impact are those who simply understand the basics very well.&lt;br&gt;
You may have to start with data structure and advance a step at a time. Studying selected topics relevant to your work and career is important.&lt;br&gt;
Thanks for reading. You can share your thoughts and suggestions in the comments.&lt;/p&gt;

&lt;p&gt;This post was originally posted at &lt;a href="https://medium.com/@Lekia/making-sense-of-computer-programming-web-development-c0741dc04ef5" rel="noopener noreferrer"&gt;https://medium.com/@Lekia/making-sense-of-computer-programming-web-development-c0741dc04ef5&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>dev</category>
      <category>web</category>
      <category>programming</category>
    </item>
    <item>
      <title>5 THINGS I WISH I KNEW YEARS AGO AS A DEVELOPER IN SECURING MY DREAM JOB</title>
      <dc:creator>Gospel Lekia</dc:creator>
      <pubDate>Mon, 22 Apr 2019 12:15:19 +0000</pubDate>
      <link>https://dev.to/goslek/5-things-i-wish-i-knew-years-ago-as-a-developer-in-securing-my-dream-job-5eim</link>
      <guid>https://dev.to/goslek/5-things-i-wish-i-knew-years-ago-as-a-developer-in-securing-my-dream-job-5eim</guid>
      <description>&lt;p&gt;Hello developer, I am glad you found this article. I wrote this with you in mind, and it is meant to guard you on this path. Why bear much burden when there is help?&lt;/p&gt;

&lt;p&gt;Life is a lot easier when there are those on whose shoulders you can climb. Here I will be sharing briefly with you some truths that will boost your velocity whether as a beginner, intermediate or you’ve been around a while.&lt;br&gt;
Becoming a developer is challenging and yet exciting. You’ve to love the job, or I should say calling. It is something you can’t do casually. It requires a consistent and conscientious effort. Discipline, dedication and diligence are not in words but in doing. Nobody pays to hear you talk as a developer, rather you are paid to do it. So, sharpening your skills is a top priority. &lt;/p&gt;

&lt;p&gt;‘Okay, enough intro let’s get to it’!!!  You are right we’re getting there. I will list them out and we'll begin. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Get a corner in the room&lt;/li&gt;
&lt;li&gt; Work your corner before inviting guest&lt;/li&gt;
&lt;li&gt; Keep up the standard&lt;/li&gt;
&lt;li&gt; Who says your dream Job is impossible?&lt;/li&gt;
&lt;li&gt; Don’t reinvent the wheels, Leverage platforms&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Get a Corner in the Room
&lt;/h2&gt;

&lt;p&gt;Joining the world of developers may sound exciting. You may have excitedly proclaimed ‘I am a developer’, only to discover your excitement just died the next minute on peeping in. You don’t have to be discouraged, we all felt that way too. &lt;br&gt;
There are millions of developers around the world and you’re just +1. This should not scare you. You are unique in the million. The community needs you. The number of developers is not important as it is that you get a corner. Look for a niche and fit yourself. This is a place where you have passion for and wish to pour your life, as life is not long enough for any of us. Choose a language and start with it till you are proficient enough. Don’t be carried away by the trends and all the buzz. Just pick a tool and master it. I mean one tool. This leads us to the next point.&lt;/p&gt;

&lt;h2&gt;
  
  
  Work your corner before inviting Guests
&lt;/h2&gt;

&lt;p&gt;This is important. Some young developers are so out to impress. This shouldn’t be your trade. You could waste precious hours if you do not plan your route as a developer. There are myriads of information available to you, but you don’t need all of them. you need to be selective where you quench your thirst. How many hours can you invest to build your skills? Information is good, but skills are what people are paying for. You have to invest time and get rid of distractions. Get to know the fundamentals, and stop jumping on resources.&lt;br&gt;
Don’t start by going for the jobs. Work on your skills enough. You can do some tasks and projects along the way but keep that big company out of it. &lt;/p&gt;

&lt;h2&gt;
  
  
  Keep Up the Standard
&lt;/h2&gt;

&lt;p&gt;You are not done yet but you are close. After building your skills and choosing your tools, it is time to go a little out. Now you’re ready to add more loads. I call this keeping up the standard. Maintaining your relevance as a developer is challenging too. This is because technology is fast evolving and there are innovations and practices almost every day. It is not easy to keep up with the trends, but you can if you have worked on your foundation adequately.&lt;br&gt;
Do research for what skills and requirements are needed to land your dream job. Add these to your cart and gradually work on them. When you’re ready attack with full force.&lt;/p&gt;

&lt;h2&gt;
  
  
  Who says your dream job is Impossible
&lt;/h2&gt;

&lt;p&gt;There are big names that scare you. It should not. It is a dream for you, so it was for others who work there currently. A man should not think of harvesting if he has not planted. But if he has observed planting season let him wait for harvest.&lt;br&gt;
Now, it is time to aim for the stars while you upgrade your skill on the side. Think of yourself as a unique developer, there are no two you on earth so what you have to offer is in you till you let it out.&lt;br&gt;
You may be asking how do I reach my employer for my dream job. Well, there are several ways around it. Few are searching, getting to their website, subscribing to their newsletter, Setting up a job alert and using social media: You have to follow that company till you find a gateway. Some of these companies float opportunities on their career platform. All you need to do is prepare and be available when the trumpet calls.  This takes me to the last point.&lt;/p&gt;

&lt;h2&gt;
  
  
  Don’t Reinvent the Wheels, Leverage on Platforms
&lt;/h2&gt;

&lt;p&gt;As a developer, you have many platforms that can help you find what you want. You can get it on a platter of gold. The problem is making your way through the ocean of information.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>career</category>
      <category>beginners</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
