<?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>Forem: steodhiambo</title>
    <description>The latest articles on Forem by steodhiambo (@steodhiambo).</description>
    <link>https://forem.com/steodhiambo</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%2F3244961%2Fbfa4dde5-71ba-4199-a7be-d9d3dd67f2f4.png</url>
      <title>Forem: steodhiambo</title>
      <link>https://forem.com/steodhiambo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/steodhiambo"/>
    <language>en</language>
    <item>
      <title>Why Good Documentation Matters (Especially for Beginners)</title>
      <dc:creator>steodhiambo</dc:creator>
      <pubDate>Tue, 08 Jul 2025 05:32:02 +0000</pubDate>
      <link>https://forem.com/steodhiambo/why-good-documentation-matters-especially-for-beginners-5e6a</link>
      <guid>https://forem.com/steodhiambo/why-good-documentation-matters-especially-for-beginners-5e6a</guid>
      <description>&lt;p&gt;When you're just starting out in software engineering, everything feels new — the tools, the syntax, the logic, even the errors. It can be overwhelming. One thing that consistently helps beginners push through the noise is &lt;strong&gt;good documentation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;But what exactly is documentation?&lt;/p&gt;

&lt;p&gt;At its core, documentation is the official guidebook for any programming language, tool, or framework. It's the source of truth — explaining what functions exist, how to use them, what parameters they take, and what you can expect in return. It often includes tutorials, code examples, best practices, and sometimes even real-world use cases.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Beginners Should Care
&lt;/h2&gt;

&lt;p&gt;For a beginner, documentation is more than just a reference. It's a mentor that doesn’t sleep.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; &lt;strong&gt;Clarity over confusion:&lt;/strong&gt; Good documentation breaks down complex ideas into digestible parts. It doesn’t assume you're an expert — it guides you like a patient teacher.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Examples that stick:&lt;/strong&gt; Seeing real, runnable code helps reinforce concepts faster than abstract theory. Many beginners learn more from examples than definitions.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Fewer dead-ends:&lt;/strong&gt; Poor documentation can feel like wandering in the dark. Quality docs save hours of frustration by making the language or tool understandable and predictable.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Confidence builder:&lt;/strong&gt; When you understand how something works, you’re more likely to experiment. This leads to faster learning and better problem-solving.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What Makes Documentation “Good”?
&lt;/h2&gt;

&lt;p&gt;Good documentation is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Beginner-friendly:&lt;/strong&gt; Clear language, no jargon, helpful intros.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Well-structured:&lt;/strong&gt; Easy to navigate, searchable, with a table of contents or sidebar.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Up-to-date:&lt;/strong&gt; Reflects the current state of the language or tool.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Example-rich:&lt;/strong&gt; Shows practical, copy-paste-ready code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Community-supported:&lt;/strong&gt; Includes feedback, community tutorials, or links to discussions (like on GitHub or Stack Overflow).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Examples That Set the Standard
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt; &lt;a href="https://developer.mozilla.org/" rel="noopener noreferrer"&gt;MDN Web Docs&lt;/a&gt; – For HTML, CSS, and JavaScript. Friendly, comprehensive, and loaded with examples.&lt;/li&gt;
&lt;li&gt; &lt;a href="https://go.dev/doc/" rel="noopener noreferrer"&gt;Go.dev&lt;/a&gt; – The Go language docs are simple, clean, and include an interactive playground.&lt;/li&gt;
&lt;li&gt; &lt;a href="https://docs.python.org/3/" rel="noopener noreferrer"&gt;Python.org&lt;/a&gt; – Extensive, but still approachable. It grows with you as you advance.&lt;/li&gt;
&lt;li&gt; &lt;a href="https://docs.djangoproject.com/" rel="noopener noreferrer"&gt;Django Docs&lt;/a&gt; – Not just a guide to the framework but also an excellent introduction to web development.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Great documentation doesn’t just support beginners — it &lt;strong&gt;empowers&lt;/strong&gt; them. It lowers the barrier to entry, encourages exploration, and makes learning feel less like a chore and more like a discovery.&lt;/p&gt;

&lt;p&gt;So if you're a beginner, lean into the docs.&lt;br&gt;&lt;br&gt;
If you're building something for others, write docs that speak to your past self — the one who didn’t know where to start. That’s how we build a better tech community for everyone.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;What are your favorite programming docs that helped you get started?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Drop them in the comments below and let’s build a helpful list for future devs!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>documentation</category>
      <category>softwaredevelopment</category>
      <category>learning</category>
    </item>
    <item>
      <title>The Art of Getting Unstuck: What Separates Senior Devs From Juniors (Hint: It's Not What You Think)</title>
      <dc:creator>steodhiambo</dc:creator>
      <pubDate>Wed, 04 Jun 2025 18:10:03 +0000</pubDate>
      <link>https://forem.com/steodhiambo/the-art-of-getting-unstuck-what-separates-senior-devs-from-juniors-hint-its-not-what-you-think-2e9</link>
      <guid>https://forem.com/steodhiambo/the-art-of-getting-unstuck-what-separates-senior-devs-from-juniors-hint-its-not-what-you-think-2e9</guid>
      <description>&lt;p&gt;&lt;em&gt;That moment when your code refuses to work, the error messages make no sense, and you're convinced you're the worst programmer alive. Sound familiar?&lt;/em&gt;&lt;br&gt;
Here's a secret that took me years to learn: &lt;strong&gt;Every developer gets stuck. Every. Single. One.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The difference between a junior developer staring at their screen for 6 hours and a senior developer solving the same problem in 30 minutes isn't raw talent or years of memorized syntax. It's something much simpler and more practical.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Great Equalizer: Everyone Hits Walls
&lt;/h2&gt;

&lt;p&gt;Whether you're debugging your first "Hello World" or architecting a distributed system, frustration is the universal developer experience. I've watched seasoned engineers with decades of experience scratch their heads at seemingly simple bugs. I've seen junior developers solve complex problems that stumped entire teams.&lt;/p&gt;

&lt;p&gt;The playing field? More level than you think.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Real Superpower: Strategic Googling
&lt;/h2&gt;

&lt;p&gt;Here's what experienced developers won't tell you in interviews: &lt;strong&gt;We Google everything.&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;That senior dev who seems to magically know every API? They're probably copy-pasting from Stack Overflow just like you. The difference is they've mastered the art of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Crafting better search queries&lt;/strong&gt; ("react useEffect cleanup function" vs "react not working")&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Recognizing reliable sources&lt;/strong&gt; (that 2-year-old Stack Overflow answer vs the random forum post)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Adapting solutions&lt;/strong&gt; rather than blindly copying code&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Your Unstuck Toolkit
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. The Copy-Paste-Search Method
&lt;/h3&gt;

&lt;p&gt;Don't be ashamed of this. Copy your exact error message and paste it into Google. You're probably the 10,000th person to encounter this exact issue. The internet is your collective brain.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. The Rubber Duck Protocol
&lt;/h3&gt;

&lt;p&gt;Explain your problem out loud to an inanimate object (or patient colleague). Half the time, you'll solve it mid-sentence. It's not magic—it's forcing your brain to organize the chaos.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. The Strategic Retreat
&lt;/h3&gt;

&lt;p&gt;Sometimes the best debugging tool is your sneakers. A 10-minute walk can untangle hours of mental knots. Your subconscious keeps working while you're away from the screen.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. The Fresh Eyes Method
&lt;/h3&gt;

&lt;p&gt;Tag in a teammate or jump into a Discord/Slack community. Fresh perspectives spot obvious issues you've been staring past for hours.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Growth Mindset Shift
&lt;/h2&gt;

&lt;p&gt;Here's what changes as you gain experience: &lt;strong&gt;You get comfortable being uncomfortable.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Junior developers often think getting stuck means they're failing. Senior developers know it means they're learning. The frustration doesn't disappear—you just develop better coping strategies and faster recovery methods.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building Your Problem-Solving Muscle
&lt;/h2&gt;

&lt;p&gt;Every time you get unstuck, you're not just solving one problem—you're building pattern recognition for future challenges. That weird CSS bug you spent three hours on today? You'll spot it in 30 seconds next time.&lt;/p&gt;

&lt;p&gt;Document your solutions. Write brief notes about what worked. Future you will thank present you.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Community Advantage
&lt;/h2&gt;

&lt;p&gt;The programming community is surprisingly generous with help. Don't suffer in silence. Platforms like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stack Overflow (for specific technical questions)&lt;/li&gt;
&lt;li&gt;Reddit's programming communities&lt;/li&gt;
&lt;li&gt;Discord servers for your tech stack&lt;/li&gt;
&lt;li&gt;Dev.to comment sections (hint, hint 😉)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Are full of people who remember being exactly where you are now.&lt;/p&gt;

&lt;h2&gt;
  
  
  Your Next Stuck Moment
&lt;/h2&gt;

&lt;p&gt;Because there will be one. Probably today. When it happens:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Take a deep breath&lt;/li&gt;
&lt;li&gt;Copy that error message&lt;/li&gt;
&lt;li&gt;Google it without shame&lt;/li&gt;
&lt;li&gt;Try the top 3 solutions&lt;/li&gt;
&lt;li&gt;If still stuck, explain it to someone (or something)&lt;/li&gt;
&lt;li&gt;Take a walk if needed&lt;/li&gt;
&lt;li&gt;Ask for help without apology&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Remember: Getting stuck isn't a bug in your developer journey—it's a feature. It means you're pushing boundaries and growing.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Your Go-To Unstuck Strategy?
&lt;/h2&gt;

&lt;p&gt;Drop a comment below with your favorite method for breaking through coding roadblocks. Let's build a collective toolkit for the next developer having one of those days.&lt;/p&gt;




</description>
      <category>programming</category>
      <category>productivity</category>
      <category>learning</category>
      <category>debugging</category>
    </item>
    <item>
      <title>Go Security for Beginners: Understanding and Protecting Your Code</title>
      <dc:creator>steodhiambo</dc:creator>
      <pubDate>Wed, 04 Jun 2025 17:35:15 +0000</pubDate>
      <link>https://forem.com/steodhiambo/go-security-for-beginners-understanding-and-protecting-your-code-oc4</link>
      <guid>https://forem.com/steodhiambo/go-security-for-beginners-understanding-and-protecting-your-code-oc4</guid>
      <description>&lt;p&gt;Security is a fundamental part of any software development process, especially when writing web applications or handling sensitive data. In this article, I'll explore some basic concepts and practices that will help you secure your Go programs and protect them from common vulnerabilities.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Should You Care About Security?
&lt;/h2&gt;

&lt;p&gt;When writing code, especially for web applications, you're not just building a product—you're creating something that users will trust. That trust hinges on keeping their data safe. A secure program prevents attackers from exploiting vulnerabilities, protecting both your users and your reputation as a developer.&lt;/p&gt;

&lt;p&gt;Just as you would lock your doors and windows to secure a house, securing your code involves adding multiple layers of protection. Ignoring security can lead to devastating consequences, such as data breaches, identity theft, or unauthorized access to sensitive information.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Security Problems (And How to Fix Them!)
&lt;/h2&gt;

&lt;p&gt;Let's look at some common security issues that beginners often overlook in Go programs and how to avoid them.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. The Username and Password Problem
&lt;/h3&gt;

&lt;p&gt;One of the most common security mistakes is storing passwords in plain text. This is like hiding a key under the doormat—anyone who finds it can gain access. Instead, passwords should always be encrypted (hashed) before storing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of What NOT to Do:&lt;/strong&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="c"&gt;// 🚫 Don't do this!&lt;/span&gt;
&lt;span class="n"&gt;username&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"john"&lt;/span&gt;
&lt;span class="n"&gt;password&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"mypassword123"&lt;/span&gt;  &lt;span class="c"&gt;// Storing passwords as plain text&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The Correct Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Go, you can use the bcrypt package to securely hash passwords:&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;// ✅ Do this instead!&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"golang.org/x/crypto/bcrypt"&lt;/span&gt;

&lt;span class="c"&gt;// When saving a password&lt;/span&gt;
&lt;span class="n"&gt;hashedPassword&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;bcrypt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GenerateFromPassword&lt;/span&gt;&lt;span class="p"&gt;([]&lt;/span&gt;&lt;span class="kt"&gt;byte&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"mypassword123"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;bcrypt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DefaultCost&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c"&gt;// Handle error&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;// When checking a password&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;bcrypt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CompareHashAndPassword&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hashedPassword&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="kt"&gt;byte&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"mypassword123"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Password is correct!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why Use bcrypt?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Hashing:&lt;/strong&gt; Instead of storing the actual password, bcrypt stores a hashed version. Even if the database is compromised, the actual password remains protected.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Salting:&lt;/strong&gt; bcrypt adds a unique salt (random data) to each password, making it resistant to rainbow table attacks (precomputed hash attacks).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. The User Input Problem
&lt;/h3&gt;

&lt;p&gt;Another common security issue is unsanitized user input, which can lead to injection attacks, such as cross-site scripting (XSS) or SQL injection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of What NOT to Do:&lt;/strong&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="c"&gt;// 🚫 Don't do this!&lt;/span&gt;
&lt;span class="n"&gt;userComment&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FormValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"comment"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Fprintf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"&amp;lt;div&amp;gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;userComment&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;"&amp;lt;/div&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c"&gt;// This is dangerous!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The Correct Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Always sanitize or escape user input before displaying it on a webpage:&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;// ✅ Do this instead!&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"html/template"&lt;/span&gt;

&lt;span class="n"&gt;userComment&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FormValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"comment"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c"&gt;// Escape special HTML characters&lt;/span&gt;
&lt;span class="n"&gt;safeComment&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;template&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;HTMLEscapeString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;userComment&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Fprintf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"&amp;lt;div&amp;gt;%s&amp;lt;/div&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;safeComment&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why Escape Input?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If a user inputs malicious code like &lt;code&gt;&amp;lt;script&amp;gt;alert('hacked!')&amp;lt;/script&amp;gt;&lt;/code&gt;, without proper escaping, this code could be executed by the browser, leading to an XSS attack. Escaping the input ensures that it is displayed as plain text, not executable code.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. The Database Query Problem
&lt;/h3&gt;

&lt;p&gt;Using raw SQL queries with user input directly in your code can lead to SQL injection, where an attacker can manipulate your SQL queries by inputting malicious SQL commands.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of What NOT to Do:&lt;/strong&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="c"&gt;// 🚫 Don't do this!&lt;/span&gt;
&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FormValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;query&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"SELECT * FROM users WHERE name = '"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;"'"&lt;/span&gt;  &lt;span class="c"&gt;// Dangerous!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The Correct Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use parameterized queries to prevent SQL injection:&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;// ✅ Do this instead!&lt;/span&gt;
&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FormValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;)&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 users WHERE name = ?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why Parameterized Queries?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Parameterized queries ensure that user inputs are treated as values rather than part of the SQL command. This prevents attackers from inserting malicious SQL code that could compromise your database.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. The Error Handling Problem
&lt;/h3&gt;

&lt;p&gt;Another overlooked security issue is exposing sensitive information through error messages. If your error messages contain too much detail, they can give attackers valuable insight into your system's structure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of What NOT to Do:&lt;/strong&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="c"&gt;// 🚫 Don't do this!&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;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&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;Error&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;StatusInternalServerError&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 example above, the &lt;code&gt;err.Error()&lt;/code&gt; message might expose sensitive information like file paths, stack traces, or database errors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Correct Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Provide generic error messages to users, and log detailed errors for developers:&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;// ✅ Do this instead!&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;Printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"An error occurred: %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="c"&gt;// Log the detailed error&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;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Internal server error"&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;StatusInternalServerError&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c"&gt;// Send a generic message to the user&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why Hide Detailed Errors?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;By showing too much detail in error messages, you may inadvertently expose vulnerabilities in your system that attackers can exploit.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. The Cross-Site Request Forgery (CSRF) Problem
&lt;/h3&gt;

&lt;p&gt;Cross-Site Request Forgery (CSRF) is an attack that tricks a user into performing actions they did not intend, such as changing their password or transferring money. Without proper protection, malicious websites could trick users into submitting forms on your site.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Correct Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To protect against CSRF, you should include a unique token in each form submission that must be verified on the server.&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;// Generate a CSRF token and add it to the form&lt;/span&gt;
&lt;span class="n"&gt;csrfToken&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;generateCSRFToken&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;tmpl&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;map&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s"&gt;"csrfToken"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;csrfToken&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c"&gt;// Validate the token when the form is submitted&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FormValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"csrfToken"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;expectedToken&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;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Invalid CSRF token"&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;StatusForbidden&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why Use CSRF Tokens?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;CSRF tokens ensure that the user submitting the form is the same one who requested it, preventing unauthorized actions.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. The HTTPS Problem
&lt;/h3&gt;

&lt;p&gt;Transport Layer Security (TLS) is essential for protecting data as it travels over the internet. Without HTTPS, attackers can intercept and manipulate traffic between the user and the server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Correct Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Always use HTTPS for communication between clients and servers. In Go, you can set up an HTTPS server like this:&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;// ✅ Do this instead!&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;ListenAndServeTLS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;":443"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"server.crt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"server.key"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure you get a valid TLS certificate from a trusted Certificate Authority (CA) or use a service like Let's Encrypt to generate certificates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Use HTTPS?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;HTTPS ensures that the data sent between your server and the user's browser is encrypted, protecting it from eavesdropping and tampering.&lt;/p&gt;

&lt;h2&gt;
  
  
  Simple Security Tips to Remember
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Check Everything:&lt;/strong&gt; Always validate and sanitize user input&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep Secrets Secret:&lt;/strong&gt; Never expose passwords or API keys in your code&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Update Regularly:&lt;/strong&gt; Keep your Go version and dependencies up to date&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use HTTPS:&lt;/strong&gt; Always secure your web applications with HTTPS&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test Security:&lt;/strong&gt; Regularly review and test your code for vulnerabilities&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to Practice Security
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Start small:&lt;/strong&gt; Implement basic security measures in small projects&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test your defenses:&lt;/strong&gt; Try to break your own code and see where it's vulnerable&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Peer reviews:&lt;/strong&gt; Ask other developers to review your code for security issues&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stay updated:&lt;/strong&gt; Follow security news and updates for Go&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;What security practices do you find most challenging in Go? Share your experiences in the comments below!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>go</category>
      <category>security</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
