惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Application and Cybersecurity Blog
Application and Cybersecurity Blog
A
About on SuperTechFans
S
SegmentFault 最新的问题
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Help Net Security
Help Net Security
有赞技术团队
有赞技术团队
博客园 - 【当耐特】
O
OpenAI News
美团技术团队
月光博客
月光博客
Apple Machine Learning Research
Apple Machine Learning Research
Schneier on Security
Schneier on Security
Webroot Blog
Webroot Blog
Cyberwarzone
Cyberwarzone
Hacker News - Newest:
Hacker News - Newest: "LLM"
Google Online Security Blog
Google Online Security Blog
T
Tenable Blog
S
Security Affairs
博客园_首页
S
Schneier on Security
Security Latest
Security Latest
T
Threat Research - Cisco Blogs
T
Tailwind CSS Blog
大猫的无限游戏
大猫的无限游戏
Spread Privacy
Spread Privacy
量子位
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
K
Kaspersky official blog
Hugging Face - Blog
Hugging Face - Blog
TaoSecurity Blog
TaoSecurity Blog
博客园 - 聂微东
Vercel News
Vercel News
M
MIT News - Artificial intelligence
T
Troy Hunt's Blog
B
Blog
MongoDB | Blog
MongoDB | Blog
Martin Fowler
Martin Fowler
Attack and Defense Labs
Attack and Defense Labs
L
LINUX DO - 最新话题
D
DataBreaches.Net
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Stack Overflow Blog
Stack Overflow Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
博客园 - Franky
W
WeLiveSecurity
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
F
Fortinet All Blogs
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Check Point Blog
H
Hacker News: Front Page

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Go Gotchas That Cost Me Hours (Learn From My Pain)
Francis Awuo · 2026-05-21 · via DEV Community

Go has burned me more than once. With bugs that felt like the language was glitching:

Channels that blocked after I’d “fixed” the blocking. Functions that kept running after hitting an error. Slices that printed data that seemingly came out of nowhere.

But as I’ve come to learn, every single time, Go was doing exactly what I asked. I just didn’t fully understand what I was asking for.

So in this article I want to share some of the “gotchas” that have cost me an embarrassing amount of time, simply because I didn’t fully understand how the language and its idioms worked.

I hope they save you some hours of pain.

Gotcha 1: Channels don't eliminate blocking. They move it.

A little while ago, I was building a mini tool that turns Linux’s Netcat into a group chat tool. Simple enough idea: multiple clients connect, one sends a message, everyone gets it. Like a mini-terminal-based WhatsApp group.

The problem with that is I ended up writing to multiple network connections (i.e., ”sending messages”) in my main loop. Which runs the risk of a slow client blocking the whole server.

func broadcast(clients []*Client, msg string) {
    for _, client := range clients {
        // writing directly to the network connection
        // a slow client blocks everyone behind it
        fmt.Fprintln(client.conn, msg)
    }
}

Enter fullscreen mode Exit fullscreen mode

So I did what felt like the obvious fix: give each client their own messages channel. That way I'm not writing to slow network connections in the main loop anymore.

type Client struct {
    conn     net.Conn
    messages chan string
}

Enter fullscreen mode Exit fullscreen mode

Each client handler reads from its channel and writes to the connection. No blocking in the main loop.

Or so I thought.

Turns out however, a slow client could still block my server.

Here's why. The channel I created was unbuffered:

messages: make(chan string)

Enter fullscreen mode Exit fullscreen mode

An unbuffered channel blocks the sender until the receiver reads from it. So if a client handler was slow writing to the network, it stopped reading from the channel. Which meant the main loop sending to that channel blocked. Which meant every other client stalled too.

I'd just pushed the blocking one step further. From the network write, into the channel send.

// main loop broadcasting to all clients
for _, client := range clients {
    client.messages <- msg // still blocks if the client handler is slow
}

Enter fullscreen mode Exit fullscreen mode

To really fix it, I had to

  1. Give the channel a reasonable buffer size (so it could accept multiple messages without blocking)
messages: make(chan string, 10)

Enter fullscreen mode Exit fullscreen mode

  1. Add a timeout for really slow clients (cause buffers can still get full)
select {
case client.messages <- msg:
    // sent
case <-time.After(time.Second):
    // client too slow, skip or disconnect
}

Enter fullscreen mode Exit fullscreen mode

Channels are great for avoiding race conditions when you’ve got concurrent code. But they, and goroutines, don’t magically fix bottlenecks.

I’d basically been running a sort of mental shortcut where goroutines + channels = fast safe code.

But that gets you into issues like this.

Gotcha 2: Slicing doesn't copy. And that will ruin your day.

This one made me want to pull my hair out. I spent a whole hour, in a coding test, staring at my code, running it again and again, trying to figure out why I was getting weird outputs.

See what I’d done was something like this:

alt := rev1[:by]
rev1 = rev1[by:]

Enter fullscreen mode Exit fullscreen mode

I split a slice in two. And then later looped through my rev1 slice while appending to alt.

for _, v := range rev1 {
    alt = append(alt, v)
}

Enter fullscreen mode Exit fullscreen mode

But here’s the thing.

Slicing in Go doesn’t make a copy. It just creates a small header pointing to the same underlying array. So alt and rev1 were sharing memory.

original := []int{1, 2, 3, 4, 5}
alt := original[:2]  // [1, 2] — but still pointing at the same array
rev1 := original[2:] // [3, 4, 5] — same array, different window

Enter fullscreen mode Exit fullscreen mode

So when I appended to alt, Go wrote into the array that rev1 was also pointing at. Which meant the slice I was iterating over was being modified while I was iterating over it.

So the values kept changing.

Leading to my weird outputs.

The fix is to force each slice onto its own backing array. The cleanest way to do that is to append data from one slice into the other. append() copies data from one slice to the other, giving each slice its own backing array. It’s own chunk of memory, if you will.

alt := append([]int{}, rev1[:by]...)

Enter fullscreen mode Exit fullscreen mode

It's one of those things that makes total sense once you understand how slices work under the hood. But until you do, it’s a head-scratcher.

Gotcha 3: make() with a length isn't an empty slice.

This one got me twice. Same bug, same confusion, different day.

I needed a slice to collect some values, so I did what felt natural:

results := make([]int, 3)

Enter fullscreen mode Exit fullscreen mode

Then later appended to it:

results = append(results, 42)

Enter fullscreen mode Exit fullscreen mode

And ended up with:

[0, 0, 0, 42]

Enter fullscreen mode Exit fullscreen mode

Not [42]. Not what I wanted.

Here's the thing. make([]int, 3) doesn't give you an empty slice with room for 3 elements. It gives you a slice with 3 elements already in it, all set to their zero value. When you append, Go doesn't replace those zeros. It adds your values after them.

If you want an empty slice with preallocated capacity, the second argument to make is length, and there's a third for capacity:

results := make([]int, 0, 3) // length 0, capacity 3
results = append(results, 42) // [42]

Enter fullscreen mode Exit fullscreen mode

Or just use a nil slice if you don't need to preallocate:

var results []int
results = append(results, 42) // [42]

Enter fullscreen mode Exit fullscreen mode

The distinction between length and capacity can be a somewhat unclear at first. Length is how many elements are in the slice right now. Capacity is how much room the underlying array has before Go needs to allocate a new one.

Gotcha 4: Forgetting to return after handling an error.

This one is less of a language quirk and more of a habit you have to build. But it's bitten me enough times to earn its spot here.

It goes like this. You're in an error block, you do something (log it, append to a slice, whatever) and then you just move on, forget to add a return statement.

func process(data []string) ([]Result, error) {
    var results []Result

    parsed, err := parse(data)
    if err != nil {
        log.Println("parse error:", err)
        // forgot to return here
    }

    // keeps running with a broken `parsed`
    for _, item := range parsed {
        results = append(results, transform(item))
    }

    return results, nil
}

Enter fullscreen mode Exit fullscreen mode

The function keeps running with broken state. And then something fails way down the line in a completely different function, and you spend twenty minutes tracing backwards trying to figure out why.

The fix is just the habit. return is part of the error block, always:

if err != nil {
    log.Println("parse error:", err)
    return nil, err
}

Enter fullscreen mode Exit fullscreen mode

Same thing applies with break and continue in loops. If your logic depends on stopping or skipping after a condition, make sure you're actually telling Go to stop or skip.

Truth be told though, even with this warning, this one will probably still get you a few times before your OCD finally kicks in and forces you to check every every error block you write.


Ones I Caught Before They Caught Me

These two didn't burn me the way the others did. I came across them early enough to file them away before making the mistake. I’m passing them on for the same reason.

Loop variable capture in goroutines

If you spin up goroutines inside a loop and reference the loop variable inside them, all the goroutines might end up using the same value, i.e., the final one the loop landed on.

items := []string{"book", "pen", "eraser"}

for _, v := range items {
    go func() {
        fmt.Println(v) // all goroutines might print "eraser"
   }()
}

Enter fullscreen mode Exit fullscreen mode

This happens because the goroutines close over v itself (see closures), not its value at the time the goroutine was created. By the time they run, the loop may have already finished.

The fix is to pass the value as an argument:

for _, v := range items {
    go func(val string) {
        fmt.Println(val) // each goroutine gets its own copy
    }(v)
}

Enter fullscreen mode Exit fullscreen mode

Worth knowing: Go 1.22 changed loop variable semantics so each iteration gets its own variable. If you're on a recent version this is less of a landmine. But a lot of codebases are still on older versions, so it's worth understanding either way.

defer in a loop

defer doesn't run at the end of each loop iteration. It runs when the surrounding function returns.

for _, path := range files {
    f, err := os.Open(path)
    if err != nil {
        continue
    }
    defer f.Close() // won't close until the whole function exits
}

Enter fullscreen mode Exit fullscreen mode

If you're opening files in a loop and deferring their close, you'll hold all of them open until the function returns. On a long-running loop that's a resource leak waiting to happen.
The fix is to wrap the body in a helper function, so defer behaves the way you intended:

func processFile(path string) error {
    f, err := os.Open(path)
    if err != nil {
        return err
    }
    defer f.Close() // now closes when processFile returns
    // ...
}

for _, path := range files {
    processFile(path)
}

Enter fullscreen mode Exit fullscreen mode

These won't be the last ones.

Go has a way of humbling you just when you think you've got a handle on it. I've fixed these bugs, written them down, but I'm certain there's a new one waiting for me in code I haven't written yet.

But while every one of these cost me time, but they also left me with a clearer picture of how the language actually works under the hood. The slice bug taught me more about memory than any article I'd read on the topic. The channel bug forced me to actually think about concurrency instead of just reaching for goroutines by habit.

So if you're hitting weird bugs in Go right now, good. Trace through them. Write them down. They're likely teaching you something.

And if you've got your own, comment them below. I'm still collecting.