<?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: Mercy Moraa</title>
    <description>The latest articles on DEV Community by Mercy Moraa (@memoraa).</description>
    <link>https://dev.to/memoraa</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3965419%2Fd6fb9e7d-4eaa-429c-9652-3b674857d044.png</url>
      <title>DEV Community: Mercy Moraa</title>
      <link>https://dev.to/memoraa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/memoraa"/>
    <language>en</language>
    <item>
      <title>Git Graph Explained: Visualizing Merge, Rebase, and Cherry-Pick</title>
      <dc:creator>Mercy Moraa</dc:creator>
      <pubDate>Mon, 03 Aug 2026 06:30:00 +0000</pubDate>
      <link>https://dev.to/memoraa/git-graph-explained-visualizing-merge-rebase-and-cherry-pick-23f0</link>
      <guid>https://dev.to/memoraa/git-graph-explained-visualizing-merge-rebase-and-cherry-pick-23f0</guid>
      <description>&lt;p&gt;Git is the ultimate tool for developers. Yet, branching strategies still confuse many of us.&lt;br&gt;
Commands like merge, rebase, and cherry-pick manipulate your commit history in completely different ways. If you just guess what they do, you risk ruining your team's shared history or losing track of your changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  The easiest way to understand Git is to visualize it. Let us look at exactly what happens to your Git graph when you run these three critical commands.
&lt;/h2&gt;

&lt;h2&gt;
  
  
  🏗️ Starting Point: Our Example Repository
&lt;/h2&gt;

&lt;p&gt;Imagine we have a standard repository. We branched off the main branch from commit B to work on a new feature in a feature branch.&lt;br&gt;
While we worked on our feature, someone else pushed commit C and D to main.&lt;br&gt;
Here is what our history looks like right now:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  C --- D  [main]
 /
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;A --- B&lt;br&gt;
     \&lt;br&gt;
      E --- F  [feature]&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;main has two new commits: C and D.&lt;/li&gt;
&lt;li&gt;feature has two new commits: E and F.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔀 1. Git Merge (The Safe Record Keeper)
&lt;/h2&gt;

&lt;p&gt;When you merge main into your feature branch (or vice versa), Git creates a special, brand-new commit called a merge commit.&lt;/p&gt;

&lt;p&gt;git checkout feature&lt;br&gt;
git merge main&lt;/p&gt;

&lt;h2&gt;
  
  
  The Visual Graph After Merge:
&lt;/h2&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  C ------- D ------ [main]
 /           \
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;A --- B           \&lt;br&gt;
     \             v&lt;br&gt;
      E --- F --- G  [feature]&lt;/p&gt;

&lt;h2&gt;
  
  
  What happened under the hood?
&lt;/h2&gt;

&lt;p&gt;Git looked at the common ancestor (B), took the history of main (C and D), took the history of feature (E and F), and combined them. Commit G is the merge commit. It has two parent commits: F and D.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pros: 100% non-destructive. It preserves the exact historical timeline of when things actually happened.&lt;/li&gt;
&lt;li&gt;Cons: Your Git graph can quickly become a messy "train track" web if you have many developers merging constantly.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🚀 2. Git Rebase (The Clean History Rewriter)
&lt;/h2&gt;

&lt;p&gt;Rebase takes all the commits from your current branch, lifts them up, and replants them on top of the very last commit of the target branch.&lt;/p&gt;

&lt;p&gt;git checkout feature&lt;br&gt;
git rebase main&lt;/p&gt;

&lt;h2&gt;
  
  
  The Visual Graph After Rebase:
&lt;/h2&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  C --- D [main]
 /       \
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;A --- B       E' --- F' [feature]&lt;/p&gt;

&lt;h2&gt;
  
  
  What happened under the hood?
&lt;/h2&gt;

&lt;p&gt;Git temporarily blew away commits E and F. It caught your feature branch up to main's latest commit (D). Then, it applied your changes back on top as brand-new commits (E' and F').&lt;br&gt;
Notice they are named E' and F' now. They have entirely new SHA hashes because their parent commit changed from B to D.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pros: Creates a perfectly linear, beautiful history. No messy merge commits.&lt;/li&gt;
&lt;li&gt;Cons: It rewrites history. Never rebase a public branch that other people are actively pulling from. You will break their local repositories.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🍒 3. Git Cherry-Pick (The Surgical Precision Tool)
&lt;/h2&gt;

&lt;p&gt;Sometimes you do not want an entire branch. You just want one specific fix or feature from another branch. Cherry-picking grabs a single commit by its SHA hash and copies it onto your current branch.&lt;br&gt;
Imagine we are back at our starting point, and we only want commit C from main, but we want to ignore commit D.&lt;/p&gt;

&lt;p&gt;git checkout feature&lt;br&gt;
git cherry-pick &lt;/p&gt;

&lt;h2&gt;
  
  
  The Visual Graph After Cherry-Pick:
&lt;/h2&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  C --- D  [main]
 /
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;A --- B&lt;br&gt;
     \&lt;br&gt;
      E --- F --- C' [feature]&lt;/p&gt;

&lt;h2&gt;
  
  
  What happened under the hood?
&lt;/h2&gt;

&lt;p&gt;Git copied the exact code changes introduced in C, generated a brand-new commit (C'), and pasted it right onto the tip of your feature branch.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pros: Highly targeted. Great for pulling a critical bug fix into a release branch without pulling unfinished features.&lt;/li&gt;
&lt;li&gt;Cons: It duplicates commits. C and C' contain the exact same changes but live in different places with different hashes.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧠 Cheat Sheet: When to Use Which?
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Best Use Case&lt;/th&gt;
&lt;th&gt;Risk Level&lt;/th&gt;
&lt;th&gt;Effect on History&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;git merge&lt;/td&gt;
&lt;td&gt;Merging a completed feature into main.&lt;/td&gt;
&lt;td&gt;🟢 Safe&lt;/td&gt;
&lt;td&gt;Preserves actual history; adds a merge commit.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;git rebase&lt;/td&gt;
&lt;td&gt;Updating your local feature branch with upstream changes before making a PR.&lt;/td&gt;
&lt;td&gt;🔴 High&lt;/td&gt;
&lt;td&gt;Rewrites history; keeps graph completely linear.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;git cherry-pick&lt;/td&gt;
&lt;td&gt;Grabbing a hotfix from a dev branch straight into production.&lt;/td&gt;
&lt;td&gt;🟡 Medium&lt;/td&gt;
&lt;td&gt;Duplicates a single commit onto your current branch.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  The Golden Rule of Git: If your branch is shared with other developers on GitHub, use merge. If the branch exists only on your local computer, use rebase to keep things clean.
&lt;/h2&gt;

&lt;p&gt;Which of these strategies does your team use at work or on open-source projects? Let me know in the comments!&lt;/p&gt;

</description>
      <category>git</category>
      <category>softwaredevelopment</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How I Pushed My .env and Database to GitHub (And How to Fix It)</title>
      <dc:creator>Mercy Moraa</dc:creator>
      <pubDate>Thu, 30 Jul 2026 08:41:33 +0000</pubDate>
      <link>https://dev.to/memoraa/how-i-pushed-my-env-and-database-to-github-and-how-to-fix-it-1g58</link>
      <guid>https://dev.to/memoraa/how-i-pushed-my-env-and-database-to-github-and-how-to-fix-it-1g58</guid>
      <description>&lt;p&gt;We have all been there. You are excited about a project, your code finally works, and you rush to push it to GitHub. You type git add ., git commit, and git push.&lt;br&gt;
Then, reality hits you. You just published your database credentials and secret API keys to a public repository.&lt;br&gt;
When I was an amateur developer, I did exactly this. I accidentally pushed both my .env file and a local SQLite database file to GitHub. It felt like the end of the world, but it was one of the best learning experiences of my career.&lt;/p&gt;

&lt;h2&gt;
  
  
  Here is exactly what went wrong, how I fixed it, and how you can prevent it from ever happening to you.
&lt;/h2&gt;

&lt;h2&gt;
  
  
  🚨 The Disaster: What Actually Happened
&lt;/h2&gt;

&lt;p&gt;Like many beginners, I treated Git like a simple backup tool rather than a version control system. I had a standard Node.js project structure:&lt;/p&gt;

&lt;p&gt;my-awesome-app/&lt;br&gt;
├── node_modules/&lt;br&gt;
├── src/&lt;br&gt;
├── .env           &amp;lt;-- Contains database passwords &amp;amp; API keys!&lt;br&gt;
├── database.db    &amp;lt;-- Contains actual application data!&lt;br&gt;
├── package.json&lt;br&gt;
└── server.js&lt;/p&gt;

&lt;p&gt;I blindly ran git add .. Because I had not configured my project to ignore confidential files, Git happily tracked .env and database.db and pushed them straight to a public GitHub repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this is dangerous:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;GitHub Scrapers: Bots constantly scan public commits for terms like DB_PASSWORD or AWS_SECRET. Your credentials can be stolen within seconds.&lt;/li&gt;
&lt;li&gt;Data Leakage: Pushing a database file exposes your users' private data or your hard-earned test data to the entire world.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  🛠️ The Immediate Fix: How to Clean It Up
&lt;/h2&gt;

&lt;p&gt;Simply deleting the file and making a new commit does not work. Git remembers everything. The sensitive files will still exist in your commit history, and anyone can look back and find them.&lt;br&gt;
If you just did this, follow these steps immediately to wipe the files from your history and secure your project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Add the files to .gitignore
&lt;/h2&gt;

&lt;p&gt;Create a file named .gitignore in your root folder (if you do not have one yet) and add these lines:&lt;/p&gt;

&lt;p&gt;.env&lt;br&gt;
*.db&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Purge the files from Git tracking
&lt;/h2&gt;

&lt;p&gt;Tell Git to stop tracking these files without deleting them from your local computer:&lt;/p&gt;

&lt;p&gt;git rm --cached .env&lt;br&gt;
git rm --cached database.db&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Completely wipe them from your history
&lt;/h2&gt;

&lt;p&gt;To completely erase the files from past commits, use the filter-repo tool or this built-in Git command:&lt;/p&gt;

&lt;p&gt;git filter-branch --force --index-filter \"git rm --cached --ignore-unmatch .env database.db" \&lt;br&gt;
--prune-empty --tag-name-filter cat -- --all&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Force push the clean history
&lt;/h2&gt;

&lt;p&gt;Update GitHub with your scrubbed history. Warning: This overwrites the remote repository.&lt;/p&gt;

&lt;p&gt;git push origin --force --all&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Rotate your secrets! (Crucial)
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Assume your keys are already compromised. Go to your database provider or API dashboard and regenerate every single password and token that was in that .env file.
&lt;/h2&gt;

&lt;h2&gt;
  
  
  🛡️ Prevention: How to Protect Your Code Moving Forward
&lt;/h2&gt;

&lt;p&gt;Mistakes happen, but automation ensures they only happen once. Here is how to bulletproof your future repositories.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Use an .env.example file
&lt;/h2&gt;

&lt;p&gt;Never leave future developers (or yourself) guessing what variables the project needs. Create an .env.example file that contains the keys but leaves the values blank. Commit this file safely to GitHub.&lt;/p&gt;

&lt;h1&gt;
  
  
  .env.example
&lt;/h1&gt;

&lt;p&gt;PORT=3000&lt;br&gt;
DATABASE_URL=your_database_url_here&lt;br&gt;
API_SECRET_KEY=your_secret_key_here&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Install a Global Gitignore
&lt;/h2&gt;

&lt;p&gt;Prevent yourself from making this mistake across all future projects. Set up a global ignore file on your computer for databases and system files.&lt;/p&gt;

&lt;p&gt;git config --global core.excludesfile ~/.gitignore_global&lt;br&gt;
echo "*.db" &amp;gt;&amp;gt; ~/.gitignore_global&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Use git-secrets or Pre-Commit Hooks
&lt;/h2&gt;

&lt;h2&gt;
  
  
  You can install tools like git-secrets or use a pre-commit hook package like husky. These tools automatically scan your code for secrets before allowing a commit to go through, blocking the action if a password or .env pattern is detected.
&lt;/h2&gt;

&lt;h2&gt;
  
  
  💡 Conclusion: Normalize Mistakes, Maximize Security
&lt;/h2&gt;

&lt;p&gt;Making mistakes is a fundamental part of the developer journey. Pushing a secret to GitHub feels terrible in the moment, but it forces you to learn about Git history management, environment isolation, and security best practices.&lt;br&gt;
Have you ever accidentally leaked a credential? What tools do you use to prevent it? Let me know in the comments below!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>git</category>
      <category>github</category>
      <category>security</category>
    </item>
    <item>
      <title>Navigating Bitcoin Core: A Developer Introduction to Scripting the Blockchain</title>
      <dc:creator>Mercy Moraa</dc:creator>
      <pubDate>Mon, 08 Jun 2026 19:31:34 +0000</pubDate>
      <link>https://dev.to/memoraa/navigating-bitcoin-core-a-developer-introduction-to-scripting-the-blockchain-5f92</link>
      <guid>https://dev.to/memoraa/navigating-bitcoin-core-a-developer-introduction-to-scripting-the-blockchain-5f92</guid>
      <description>&lt;p&gt;Most developers look at blockchain technology from a high-level perspective, interacting only with distant third-party APIs or abstract web3 libraries. But if you want to understand the raw operational realities of decentralized networks, you have to look under the hood.&lt;/p&gt;

&lt;p&gt;Interacting directly with a local node bypasses the middleman, offering complete control over wallet structures, manual block mining, and ledger analysis.&lt;/p&gt;

&lt;p&gt;Let us break down the exact operational steps required to initialize a local Bitcoin testing architecture, manage automated transaction states, and lay the foundation for script-driven interactions.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Foundation: Localized Testing Environments
&lt;/h2&gt;

&lt;p&gt;When developing network applications, testing logic on a live public network is highly inefficient. Instead, developers rely on local environments like &lt;strong&gt;Regtest&lt;/strong&gt; (Regression Test).&lt;/p&gt;

&lt;p&gt;Unlike a public Testnet, a Regtest environment is a completely private, isolated blockchain network created instantly on your local machine. You possess absolute authority over the network dynamics: you can simulate network latency, generate blocks on demand without complex computing hardware, and instantly fund test wallets.&lt;/p&gt;

&lt;h3&gt;
  
  
  Initializing Bitcoin Core for Development
&lt;/h3&gt;

&lt;p&gt;To configure a local sandbox, your daemon configuration file (&lt;code&gt;bitcoin.conf&lt;/code&gt;) requires explicit settings to ensure isolation and enable external control capabilities:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="c"&gt;# Force running on a local, private regression testing network
&lt;/span&gt;&lt;span class="py"&gt;regtest&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;

&lt;span class="c"&gt;# Run the daemon in the background as a headless service
&lt;/span&gt;&lt;span class="py"&gt;daemon&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;

&lt;span class="c"&gt;# Enable the JSON-RPC HTTP server for external application scripts
&lt;/span&gt;&lt;span class="py"&gt;server&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;

&lt;span class="c"&gt;# Explicit authentication credentials for software connections
&lt;/span&gt;&lt;span class="py"&gt;rpcuser&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;dev_user&lt;/span&gt;
&lt;span class="py"&gt;rpcpassword&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;secure_dev_password&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;With these parameters active, starting the service creates a fresh genesis block, ready for programmatic operations.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 1: Wallet Topology and Address Derivation
&lt;/h2&gt;

&lt;p&gt;In modern cryptographic ledgers, wallets are collections of keys rather than physical containers of coins. Interaction begins by initializing a dedicated descriptor wallet via the Command Line Interface (CLI).&lt;/p&gt;

&lt;p&gt;Using the native interface, creating a baseline wallet requires pointing directly to your local runtime instance:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bitcoin-cli &lt;span class="nt"&gt;-regtest&lt;/span&gt; createwallet &lt;span class="s2"&gt;"dev_wallet_alpha"&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Once a secure container exists, the node can calculate individual receiving destinations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Address Variations and SegWit
&lt;/h3&gt;

&lt;p&gt;When requesting a new address, you have to choose an address format. Bitcoin architecture has evolved through several major structural shifts, impacting fee optimization and validation rules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Legacy (P2PKH):&lt;/strong&gt; Addresses starting with a &lt;code&gt;1&lt;/code&gt;. They represent old-school transaction structures where scripts are explicitly exposed on the ledger.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Nested SegWit (P2SH):&lt;/strong&gt; Addresses starting with a &lt;code&gt;3&lt;/code&gt;. This format acts as a wrapper, allowing legacy software to interact with modernized protocol optimizations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Native SegWit (Bech32):&lt;/strong&gt; Addresses starting with &lt;code&gt;bc1q&lt;/code&gt;. This is the optimized standard for modern systems. It drastically reduces transaction data size by splitting signature data (witness) from the main transactional block, directly lowering transaction fees.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To generate a modern Native SegWit destination key for testing, execute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bitcoin-cli &lt;span class="nt"&gt;-regtest&lt;/span&gt; getnewaddress &lt;span class="s2"&gt;"funding_node"&lt;/span&gt; &lt;span class="s2"&gt;"bech32"&lt;/span&gt;

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

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 2: Minting Blocks and Earning Coinbase Rewards
&lt;/h2&gt;

&lt;p&gt;On a live network, mining blocks requires immense thermodynamic computational energy. On a Regtest node, however, you can trigger block production instantly using structural developer commands.&lt;/p&gt;

&lt;p&gt;When a block is appended to the ledger, the system awards a &lt;strong&gt;Coinbase Reward&lt;/strong&gt;—newly minted tokens allocated to the block producer. This is the mechanism used to fund a local development environment.&lt;/p&gt;

&lt;p&gt;To mint blocks and deposit the rewards into your newly generated address:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bitcoin-cli &lt;span class="nt"&gt;-regtest&lt;/span&gt; generatetoaddress 101 &lt;span class="s2"&gt;"bc1q..."&lt;/span&gt;

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  The 100-Block Maturity Rule
&lt;/h3&gt;

&lt;p&gt;Notice the parameter &lt;code&gt;101&lt;/code&gt;. In the protocol code, coinbase rewards cannot be spent immediately. They are subject to a &lt;strong&gt;100-block maturity rule&lt;/strong&gt;. A minted reward must be buried under at least 100 subsequent blocks before the network consensus rules permit it to be used as an input for a standard transaction. Minting 101 blocks unlocks the reward from the very first block, giving you an active spendable balance.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 3: Transaction Structuring and Ledger Analysis
&lt;/h2&gt;

&lt;p&gt;With an active spendable balance, you can simulate asset movement across separate local entities.&lt;/p&gt;

&lt;p&gt;When you instruct a wallet to transfer value, the node automatically builds a new transaction, signs it using your private keys, and broadcasts it to the local memory pool (mempool) awaiting validation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bitcoin-cli &lt;span class="nt"&gt;-regtest&lt;/span&gt; sendtoaddress &lt;span class="s2"&gt;"bc1q_destination_address_here"&lt;/span&gt; 1.5

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

&lt;/div&gt;



&lt;p&gt;At this stage, the transaction is unconfirmed. It sits in a pending state until you execute another &lt;code&gt;generatetoaddress&lt;/code&gt; command to forge a new block, sealing the transaction into the ledger history.&lt;/p&gt;

&lt;h3&gt;
  
  
  Programmatic Inspection
&lt;/h3&gt;

&lt;p&gt;To analyze the block contents or inspect individual transaction data arrays directly from the node storage records, use the tracking hashes provided by the runtime logs:&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="c"&gt;# Retrieve full data array regarding a specific block ID&lt;/span&gt;
bitcoin-cli &lt;span class="nt"&gt;-regtest&lt;/span&gt; getblock &lt;span class="s2"&gt;"block_hash_string"&lt;/span&gt;

&lt;span class="c"&gt;# Inspect the exact inputs, outputs, and validation signatures of a transaction&lt;/span&gt;
bitcoin-cli &lt;span class="nt"&gt;-regtest&lt;/span&gt; getrawtransaction &lt;span class="s2"&gt;"txid_string"&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Analyzing this raw JSON data exposes the core design of the network: an interconnected chain of &lt;strong&gt;UTXOs (Unspent Transaction Outputs)&lt;/strong&gt;, where every transaction completely consumes old outputs to generate fresh ones.&lt;/p&gt;




&lt;h2&gt;
  
  
  Moving Forward: Automation with Python
&lt;/h2&gt;

&lt;p&gt;Manually typing terminal commands is fine for initial exploration, but production-grade development requires automation. Because Bitcoin Core exposes a standard JSON-RPC interface, you can completely automate your local node using Python.&lt;/p&gt;

&lt;p&gt;Instead of writing raw HTTP network wrappers, you can leverage the native &lt;code&gt;authproxy&lt;/code&gt; library provided in the official source code, allowing you to trigger actions programmatically:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;bitcoinrpc.authproxy&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;AuthServiceProxy&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;JSONRPCException&lt;/span&gt;

&lt;span class="c1"&gt;# Connect directly to the local Regtest daemon using your configuration file settings
&lt;/span&gt;&lt;span class="n"&gt;rpc_connection&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;AuthServiceProxy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;http://dev_user:secure_dev_password@127.0.0.1:18443&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Retrieve system info programmatically
&lt;/span&gt;    &lt;span class="n"&gt;blockchain_info&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;rpc_connection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getblockchaininfo&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Current Block Height: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;blockchain_info&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;blocks&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Automate address creation
&lt;/span&gt;    &lt;span class="n"&gt;new_addr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;rpc_connection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getnewaddress&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;automated_script_wallet&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Generated Automated Destination: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;new_addr&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="n"&gt;JSONRPCException&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;RPC Error detected: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Connecting Python automation scripts directly to a secure local node unlocks endless possibilities. You can safely build automated tax compliance tools, custom auditing trackers, or real-time cryptographic accounting systems without any reliance on third-party frameworks.&lt;/p&gt;

&lt;p&gt;The power of the decentralized web lies in self-sovereign code execution. Run your own nodes, analyze the raw primitives, and write clean, resilient systems.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>bitcoin</category>
      <category>python</category>
      <category>blockchain</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Building ML Pipelines with Python: From Data to Insights</title>
      <dc:creator>Mercy Moraa</dc:creator>
      <pubDate>Sun, 07 Jun 2026 01:32:13 +0000</pubDate>
      <link>https://dev.to/memoraa/building-ml-pipelines-with-python-from-data-to-insights-3bkc</link>
      <guid>https://dev.to/memoraa/building-ml-pipelines-with-python-from-data-to-insights-3bkc</guid>
      <description>&lt;p&gt;In machine learning, writing a script that trains a model on a clean dataset is only a fraction of the work. The real challenge lies in building a system that can reliably ingest raw data, transform it, train a model, and serve predictions in production.&lt;/p&gt;

&lt;p&gt;When code is written as a series of disconnected Jupyter Notebook cells, it inevitably becomes brittle, difficult to test, and prone to data leakage. The solution is to transition from isolated scripts to structured &lt;strong&gt;Machine Learning Pipelines&lt;/strong&gt;. A pipeline automates the workflow, ensures reproducibility, and bridges the gap between data science and software engineering.&lt;/p&gt;

&lt;p&gt;Let us build an end-to-end Machine Learning pipeline using pure Python and the industry-standard &lt;code&gt;scikit-learn&lt;/code&gt; framework.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is an ML Pipeline?
&lt;/h2&gt;

&lt;p&gt;An ML pipeline binds data preprocessing steps and model execution into a single, cohesive software element.&lt;/p&gt;

&lt;p&gt;Instead of manually applying transformations to your training data and remembering to apply those exact same transformations to your testing data, the pipeline executes the sequence automatically. This design completely eliminates &lt;strong&gt;data leakage&lt;/strong&gt;—a common error where information from outside the training dataset is accidentally used to train the model, leading to overly optimistic but invalid evaluation metrics.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 1: Setting Up the Environment
&lt;/h2&gt;

&lt;p&gt;To follow along, initialize a clean workspace and install the core data science libraries:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;numpy pandas scikit-learn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 2: Designing the Complete Pipeline Code
&lt;/h2&gt;

&lt;p&gt;We will build a pipeline that handles a realistic, messy dataset containing both numerical features (which need scaling) and categorical features (which need encoding), followed by a classification model.&lt;/p&gt;

&lt;p&gt;Create a file named &lt;code&gt;pipeline.py&lt;/code&gt; and implement the following structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pandas&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.model_selection&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;train_test_split&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.compose&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;ColumnTransformer&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.pipeline&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Pipeline&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.impute&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SimpleImputer&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.preprocessing&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;StandardScaler&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;OneHotEncoder&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.ensemble&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;RandomForestClassifier&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.metrics&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;classification_report&lt;/span&gt;

&lt;span class="c1"&gt;# 1. Simulate a realistic raw dataset
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;generate_mock_data&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;seed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;n_samples&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;

    &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;age&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;choice&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nan&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;34&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;45&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;52&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;61&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;n_samples&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;income&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;choice&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;50000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;80000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;120000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nan&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;n_samples&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;department&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;choice&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Sales&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Engineering&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Marketing&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;n_samples&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;purchased&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;choice&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;n_samples&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0.7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.3&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;# Replace the string "None" with proper NaN values so the imputer can detect them
&lt;/span&gt;    &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;department&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;department&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;None&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nan&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="c1"&gt;# Load raw data
&lt;/span&gt;    &lt;span class="n"&gt;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;generate_mock_data&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;# Separate features (X) and target label (y)
&lt;/span&gt;    &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;drop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;purchased&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;purchased&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="c1"&gt;# Split into train and test sets before any preprocessing occurs
&lt;/span&gt;    &lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X_test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;train_test_split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;test_size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;random_state&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# 2. Define feature groups
&lt;/span&gt;    &lt;span class="n"&gt;numeric_features&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;age&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;income&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;categorical_features&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;department&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="c1"&gt;# 3. Create sub-transformers for different data types
&lt;/span&gt;    &lt;span class="n"&gt;numeric_transformer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Pipeline&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;steps&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;imputer&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;SimpleImputer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;strategy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;median&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;   &lt;span class="c1"&gt;# Fill missing values with median
&lt;/span&gt;        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;scaler&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;StandardScaler&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;                     &lt;span class="c1"&gt;# Scale values to standard normal distribution
&lt;/span&gt;    &lt;span class="p"&gt;])&lt;/span&gt;

    &lt;span class="n"&gt;categorical_transformer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Pipeline&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;steps&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;imputer&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;SimpleImputer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;strategy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;most_frequent&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;  &lt;span class="c1"&gt;# Fill missing text with mode
&lt;/span&gt;        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;encoder&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;OneHotEncoder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;handle_unknown&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ignore&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;     &lt;span class="c1"&gt;# Convert text strings to numeric vectors
&lt;/span&gt;    &lt;span class="p"&gt;])&lt;/span&gt;

    &lt;span class="c1"&gt;# 4. Combine transformers using ColumnTransformer
&lt;/span&gt;    &lt;span class="n"&gt;preprocessor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ColumnTransformer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;transformers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;num&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;numeric_transformer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;numeric_features&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;cat&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;categorical_transformer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;categorical_features&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# 5. Build the master pipeline (Preprocessing + Model Estimator)
&lt;/span&gt;    &lt;span class="n"&gt;clf_pipeline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Pipeline&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;steps&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;preprocessor&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;preprocessor&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;classifier&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;RandomForestClassifier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n_estimators&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;random_state&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;])&lt;/span&gt;

    &lt;span class="c1"&gt;# 6. Train the entire pipeline with a single call
&lt;/span&gt;    &lt;span class="c1"&gt;# Transformations are fitted strictly on training data
&lt;/span&gt;    &lt;span class="n"&gt;clf_pipeline&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_train&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# 7. Evaluate performance
&lt;/span&gt;    &lt;span class="c1"&gt;# Test data is passed through the pre-fit transformations automatically
&lt;/span&gt;    &lt;span class="n"&gt;predictions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;clf_pipeline&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_test&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;--- Model Performance Metrics ---&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;classification_report&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y_test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;predictions&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;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 3: Unpacking the Architectural Choices
&lt;/h2&gt;

&lt;h3&gt;
  
  
  ColumnTransformer
&lt;/h3&gt;

&lt;p&gt;Real-world data is heterogeneous. Your code needs to treat numerical values differently than strings. The &lt;code&gt;ColumnTransformer&lt;/code&gt; lets you isolate specific columns and apply dedicated processing sub-pipelines to them in parallel, before stitching them back together into a unified matrix for the machine learning algorithm.&lt;/p&gt;

&lt;h3&gt;
  
  
  Streamlined Inference
&lt;/h3&gt;

&lt;p&gt;Notice the execution phase: &lt;code&gt;clf_pipeline.fit(X_train, y_train)&lt;/code&gt; handles the entire transformation and training sequence. When it is time to make a prediction on new, raw data, you simply call &lt;code&gt;clf_pipeline.predict(X_new)&lt;/code&gt;. You do not need to repeat the code for scaling or filling empty data blocks; the pipeline remembers the mathematical rules established during the training step.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 4: Production Deployment Strategy
&lt;/h2&gt;

&lt;p&gt;Once your pipeline compiles and performs well, it needs to move out of your local development environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Model Serialization
&lt;/h3&gt;

&lt;p&gt;To save the entire trained pipeline—including both the data preprocessing weights and the model parameters—use &lt;code&gt;joblib&lt;/code&gt;. It is the recommended serialization tool in the scikit-learn ecosystem as it handles large numpy arrays more efficiently than &lt;code&gt;pickle&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;joblib&lt;/span&gt;

&lt;span class="c1"&gt;# Persist the entire trained pipeline object to disk
&lt;/span&gt;&lt;span class="n"&gt;joblib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;clf_pipeline&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ml_pipeline.pkl&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To load the pipeline later for inference:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Load the pipeline in a production script or notebook
&lt;/span&gt;&lt;span class="n"&gt;clf_pipeline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;joblib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ml_pipeline.pkl&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Predict on brand new raw data
&lt;/span&gt;&lt;span class="n"&gt;predictions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;clf_pipeline&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new_data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Serving via API
&lt;/h3&gt;

&lt;p&gt;In a production deployment, an API service layer (such as FastAPI) loads this single serialized file into memory on startup. When a user submits raw data via a JSON endpoint, the raw payload is converted directly into a Pandas DataFrame and passed straight to &lt;code&gt;.predict()&lt;/code&gt;. This structural cleanliness guarantees that data transformations in production match your training conditions exactly.&lt;/p&gt;




&lt;h2&gt;
  
  
  Summary Principles for Clean ML Engineering
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Split First, Transform Second:&lt;/strong&gt; Always execute &lt;code&gt;train_test_split&lt;/code&gt; before configuring transforms. If you calculate the mean or median of a column using the entire dataset, your model is subtly cheating by seeing data from the test set.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Handle Missing Values Correctly:&lt;/strong&gt; Ensure that placeholder strings like &lt;code&gt;"None"&lt;/code&gt; or &lt;code&gt;"NaN"&lt;/code&gt; are converted to proper &lt;code&gt;np.nan&lt;/code&gt; values so that &lt;code&gt;SimpleImputer&lt;/code&gt; can detect and fill them appropriately. Failing to do this treats them as valid categories and introduces noise into your model.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Handle Unknown Labels:&lt;/strong&gt; When configuring categorical encoders, always include parameters like &lt;code&gt;handle_unknown='ignore'&lt;/code&gt;. This prevents your API from crashing if a user inputs a completely new category in production that wasn't present during training.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Version Your Artifacts:&lt;/strong&gt; Treat your pipeline binary file like source code. If the data schemas or hyperparameters change, tag the exported file version cleanly so you can easily rollback if production anomalies occur.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Transitioning from raw scripting blocks to structured object-oriented pipelines makes your code reliable, clean, and immediately ready for modern deployment architectures.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>python</category>
      <category>machinelearning</category>
      <category>datascience</category>
    </item>
    <item>
      <title>Getting Started with Go: A Beginner's Journey</title>
      <dc:creator>Mercy Moraa</dc:creator>
      <pubDate>Sun, 07 Jun 2026 01:14:00 +0000</pubDate>
      <link>https://dev.to/memoraa/getting-started-with-go-a-beginners-journey-1491</link>
      <guid>https://dev.to/memoraa/getting-started-with-go-a-beginners-journey-1491</guid>
      <description>&lt;p&gt;If you told me a few months ago that I would be obsessed with pointers, memory allocation, and low-level strings manipulation, I probably would have laughed. But here I am, deep into a rigorous technical software development program, and completely falling in love with Go (Golang).&lt;/p&gt;

&lt;p&gt;Go was designed by Google to be simple, blazing fast, and highly concurrent. While it handles heavy backend architectures globally, it is also one of the most rewarding languages to learn as a beginner, no matter where you are in the world.&lt;/p&gt;

&lt;p&gt;In this article, I want to share my raw insights from an intense tech training environment, unpack Go's fundamental layout, and help you build your very first Command Line Interface (CLI) application using nothing but the Go Standard Library. No cheat frameworks. No heavy external dependencies. Just raw logic.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Go?
&lt;/h2&gt;

&lt;p&gt;When you start learning Go in a strict environment, you quickly realize it doesn't hold your hand like Python, but it isn't as terrifyingly manual as C. It sits in the perfect sweet spot:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Strict Compilation:&lt;/strong&gt; If you import a package or declare a variable and don't use it, your code will not compile. This forces you to write clean, minimal code from day one.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Blazing Fast:&lt;/strong&gt; It compiles directly to machine code, which means it runs incredibly fast.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Standard Library Power:&lt;/strong&gt; Go’s built-in tools (net/http, os, strconv) are so powerful that you rarely need to download external packages to build production-grade tools.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 1: Setting Up Your Workspace
&lt;/h2&gt;

&lt;p&gt;Before writing code, initialize your project workspace. Open your 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;&lt;span class="nb"&gt;mkdir &lt;/span&gt;go-beginner-cli
&lt;span class="nb"&gt;cd &lt;/span&gt;go-beginner-cli
go mod init go-beginner-cli

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

&lt;/div&gt;



&lt;p&gt;This creates a go.mod file, which manages your application's path and dependencies.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Understanding the Base Structure
&lt;/h2&gt;

&lt;p&gt;Every execution file in Go follows a strict anatomy. Create a main.go file and inspect this template:&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;"fmt"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello, World!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  The Breakdown:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;package main&lt;/strong&gt;: Tells the Go compiler that this file should compile as an executable program rather than a shared utility library.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;import&lt;/strong&gt;: Brings in standard tools. Here, "fmt" (Format) handles console input and output.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;func main()&lt;/strong&gt;: The ultimate entry point. When you run your program, execution starts exactly here.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To execute it, 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 main.go

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 3: Building Your First App ; A Dynamic CLI Case Converter
&lt;/h2&gt;

&lt;p&gt;Let’s move past "Hello World" and build a practical CLI application. We will write a tool that accepts a string argument from the terminal and modifies it based on what the user wants (Uppercase or Lowercase).&lt;/p&gt;

&lt;p&gt;We will use the native os package to capture terminal input arguments (os.Args).&lt;/p&gt;

&lt;p&gt;Replace the contents of main.go with the following code:&lt;br&gt;
&lt;/p&gt;

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

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"fmt"&lt;/span&gt;
    &lt;span class="s"&gt;"os"&lt;/span&gt;
    &lt;span class="s"&gt;"strings"&lt;/span&gt;
&lt;span class="p"&gt;)&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="c"&gt;// os.Args[0] is always the program name itself.&lt;/span&gt;
    &lt;span class="c"&gt;// We expect: program_name, string_to_modify, and mode (up/low)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&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;Args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="m"&gt;3&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;"Usage: go run . [text] [up|low]"&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;inputText&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;Args&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;mode&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;Args&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="k"&gt;switch&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s"&gt;"up"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;strings&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ToUpper&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inputText&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;"Result:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s"&gt;"low"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;strings&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ToLower&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inputText&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;"Result:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="o"&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;"Unknown mode! Use 'up' for uppercase or 'low' for lowercase."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  How to Run Your New CLI Tool:
&lt;/h3&gt;

&lt;p&gt;Test your application directly from your terminal pane by passing arguments:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test 1: Uppercase Mod&lt;/strong&gt;&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;span class="s2"&gt;"learning go is awesome"&lt;/span&gt; up
&lt;span class="c"&gt;# Output: Result: LEARNING GO IS AWESOME&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Test 2: Lowercase Mod&lt;/strong&gt;&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;span class="s2"&gt;"GLOBAL DEVELOPERS"&lt;/span&gt; low
&lt;span class="c"&gt;# Output: Result: global developers&lt;/span&gt;

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Key Takeaways from My Learning Journey
&lt;/h2&gt;

&lt;p&gt;Building text manipulation tools and algorithmic blueprints from scratch taught me three vital lessons:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Think in Runes, Not Just Strings:&lt;/strong&gt; In Go, strings are read-only slices of bytes. If you want to handle text properly without breaking special characters, learn to convert your data into []rune.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Handle Errors Safely:&lt;/strong&gt; Go doesn't use traditional try/catch exceptions. Functions return data and errors explicitly side-by-side. It forces you to deal with errors immediately.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep it Simple:&lt;/strong&gt; The beauty of Go lies in its minimalism. If your function is getting too complex, break it down into smaller structural files under package main.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Wrap Up
&lt;/h2&gt;

&lt;p&gt;This is just the baseline of what you can accomplish. Once you master string tracking and the basic os filesystem controls, you can transition into building full file processors, custom parsers, or high-performance APIs.&lt;/p&gt;

&lt;p&gt;Are you currently learning Go or thinking about diving in? Let’s connect in the comments below! Share your favorite Go optimization tips or ask any questions if you are stuck on your own learning pipeline.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

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