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

推荐订阅源

cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Security Archives - TechRepublic
Security Archives - TechRepublic
Forbes - Security
Forbes - Security
C
Cyber Attacks, Cyber Crime and Cyber Security
Latest news
Latest news
V2EX - 技术
V2EX - 技术
Google DeepMind News
Google DeepMind News
Cyberwarzone
Cyberwarzone
Vercel News
Vercel News
V
Vulnerabilities – Threatpost
I
InfoQ
GbyAI
GbyAI
有赞技术团队
有赞技术团队
雷峰网
雷峰网
阮一峰的网络日志
阮一峰的网络日志
A
Arctic Wolf
F
Full Disclosure
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Check Point Blog
Hugging Face - Blog
Hugging Face - Blog
Simon Willison's Weblog
Simon Willison's Weblog
Google DeepMind News
Google DeepMind News
M
MIT News - Artificial intelligence
Engineering at Meta
Engineering at Meta
The Register - Security
The Register - Security
T
Tor Project blog
T
Troy Hunt's Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Security Affairs
W
WeLiveSecurity
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Stack Overflow Blog
Stack Overflow Blog
Apple Machine Learning Research
Apple Machine Learning Research
H
Heimdal Security Blog
S
Secure Thoughts
Y
Y Combinator Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Security Latest
Security Latest
Martin Fowler
Martin Fowler
G
Google Developers Blog
宝玉的分享
宝玉的分享
腾讯CDC
TaoSecurity Blog
TaoSecurity Blog
T
Threatpost
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Project Zero
Project Zero
Blog — PlanetScale
Blog — PlanetScale
大猫的无限游戏
大猫的无限游戏
MongoDB | Blog
MongoDB | Blog

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
The Dependency Rule, Written as a CI Check in Go
Gabriel Anha · 2026-05-01 · via DEV Community

You wrote the architecture doc. The team agreed in the meeting. The PR description says "follows hexagonal." Six months later, you open internal/domain/order.go and the import block reads database/sql, net/http, and github.com/aws/aws-sdk-go-v2/service/s3. Nobody noticed when those crept in. They rode in on a Friday afternoon merge, past two senior reviewers running on coffee.

Architecture rules that live only in your head do not survive the second quarter of a service's life. The fix is to encode the rule the same way you encode any other invariant: as a check that fails the build.

This post walks through three ways to do that for the hexagonal dependency rule (domain imports nothing from adapter/... and nothing transport-shaped from the standard library). Pick whichever fits your stack.

The rule, written down

In a hexagonal Go service, the dependency arrows point inward. Adapters know about the domain. The domain knows about ports (its own interfaces). Nothing in the domain imports anything that is database-shaped, transport-shaped, or vendor-shaped.

Concretely, for a project laid out like this:

internal/
  domain/        # business logic, port interfaces
  adapter/
    postgres/    # implements ports
    http/        # inbound transport
  port/          # optional alias for domain interfaces
cmd/
  server/        # main(), the composition root

Enter fullscreen mode Exit fullscreen mode

The forbidden imports inside internal/domain/... are roughly:

  • database/sql and its driver subpackage
  • net/http, net/rpc
  • encoding/json, encoding/xml (arguable: DTOs live in adapters)
  • Anything under internal/adapter/...
  • Most third-party paths: github.com/..., gitlab.com/..., cloud.google.com/...

That list is your CI contract. Now you need a robot to read it.

Option 1: a 40-line bash check using go list

Start with the cheapest thing that works. The Go toolchain already knows what every package imports. go list will print it.

#!/usr/bin/env bash
# scripts/check-domain-imports.sh
set -euo pipefail

DOMAIN_PKG="./internal/domain/..."

FORBIDDEN=(
  "database/sql"
  "net/http"
  "net/rpc"
  "github.com/"
  "gitlab.com/"
  "cloud.google.com/"
  "internal/adapter/"
)

Enter fullscreen mode Exit fullscreen mode

The script asks go list for the transitive closure of every package under the domain, then greps for anything on the forbidden list:

IMPORTS=$(go list -deps -f '{{.ImportPath}}' \
  "$DOMAIN_PKG" | sort -u)

FAILED=0
for pat in "${FORBIDDEN[@]}"; do
  hits=$(echo "$IMPORTS" | grep -F "$pat" || true)
  if [ -n "$hits" ]; then
    echo "FORBIDDEN import in domain: ${pat}"
    echo "$hits" | sed 's/^/  /'
    FAILED=1
  fi
done

if [ "$FAILED" -ne 0 ]; then
  echo "domain dependency rule violated"
  exit 1
fi

echo "domain imports are clean"

Enter fullscreen mode Exit fullscreen mode

Two pieces are doing the work. go list -deps walks the transitive closure and emits one line per package in it, so a domain package that imports a helper that imports database/sql still gets caught. grep -F matches each forbidden pattern as a substring against those lines, which is why internal/adapter/ works regardless of your module path: the actual go list output looks like github.com/acme/orders/internal/adapter/postgres, and the substring is right there in the middle.

Wire it into your pipeline. GitHub Actions:

- name: domain dependency rule
  run: ./scripts/check-domain-imports.sh

Enter fullscreen mode Exit fullscreen mode

Forty lines of bash, zero new dependencies, runs in well under a second on a normal repo. It is also brittle: a typo in the forbidden list silently passes, and you cannot describe layered relationships ("port may import domain but not the other way around"). For one boundary on one team, that is fine. For a real architecture, you want something with structure.

Option 2: go-arch-lint for the layered rule set

go-arch-lint (MIT-licensed, by Vadim Kulibaba — fe3dback on GitHub) is the dedicated tool for this. You describe your components and the allowed dependency edges in a YAML file; the linter walks your import graph and yells when an edge is missing from the allowlist. Verified against the project's v1.14.0 syntax docs, the v3 config for the layout above looks like this:

version: 3

components:
  domain:
    in: internal/domain/**
  port:
    in: internal/port/**
  adapter:
    in: internal/adapter/**
  cmd:
    in: cmd/server/**

commonComponents:
  - port

deps:
  domain:
    mayDependOn:
      - port
  adapter:
    mayDependOn:
      - domain
      - port
  cmd:
    mayDependOn:
      - domain
      - adapter
      - port

Enter fullscreen mode Exit fullscreen mode

No workdir: here. The project's own canonical config uses workdir: internal, but that resolves every in: path relative to the workdir, and v3 does not let you escape it with ../. Writing globs from the repo root (internal/domain/**, cmd/server/**) keeps the config flat and lets cmd sit alongside internal without contortions.

Read it as a graph. domain only points at port. adapter points inward at domain. cmd is the composition root and is allowed to see everyone. There is no edge from domain to adapter, so any new import that crosses that line is a violation.

Run it locally first. Pin the version rather than @latest so CI does not silently pick up a breaking release:

go install github.com/fe3dback/go-arch-lint@v1.14.0
go-arch-lint check --project-path .

Enter fullscreen mode Exit fullscreen mode

Then add it to CI:

- name: install go-arch-lint
  run: go install github.com/fe3dback/go-arch-lint@v1.14.0

- name: arch lint
  run: go-arch-lint check --project-path .

Enter fullscreen mode Exit fullscreen mode

The win over the bash script: the rule reads like architecture instead of like a regex. A new engineer reading .go-arch-lint.yml sees the layering at a glance. Adding an application tier between port and domain is one new edge in the YAML, not a new clause in a shell loop.

One caveat. go-arch-lint reasons about your packages, not raw stdlib paths. If you specifically want to ban database/sql from anywhere in the domain — even when it sneaks in via a helper that lives inside the domain component — pair go-arch-lint with the bash check above. They cover different angles.

Option 3: a custom analyzer with golang.org/x/tools/go/analysis

When you need rules that are uniquely yours — "no imports from domain/... to adapter/..., with the file and line of the offending import in the error message, integrated into go vet and your editor" — write a tiny analyzer. Verified against the analysis package docs and the singlechecker docs, the whole thing fits in fifty lines.

The full file:

// cmd/hexlint/main.go
package main

import (
    "strings"

    "golang.org/x/tools/go/analysis"
    "golang.org/x/tools/go/analysis/singlechecker"
)

var Analyzer = &analysis.Analyzer{
    Name: "hexlint",
    Doc:  "domain may not import adapter",
    Run:  run,
}

func main() { singlechecker.Main(Analyzer) }

func run(pass *analysis.Pass) (interface{}, error) {
    pkg := pass.Pkg.Path()
    if !strings.Contains(pkg, "/internal/domain") {
        return nil, nil
    }

    for _, file := range pass.Files {
        for _, imp := range file.Imports {
            path := strings.Trim(imp.Path.Value, `"`)
            if isForbidden(path) {
                pass.Reportf(
                    imp.Pos(),
                    "domain imports forbidden package %q",
                    path,
                )
            }
        }
    }
    return nil, nil
}

func isForbidden(path string) bool {
    switch {
    case strings.Contains(path, "/internal/adapter/"):
        return true
    case path == "database/sql",
         path == "net/http",
         path == "encoding/json":
        return true
    }
    return false
}

Enter fullscreen mode Exit fullscreen mode

pass.Pkg.Path() tells you which package is being analyzed. pass.Pkg.Imports() gives you what it imports. For each import that crosses the forbidden boundary, pass.Reportf carries the position of the offending import spec so editors and CI both highlight the right line.

Build and run it like any other Go program:

go build -o bin/hexlint ./cmd/hexlint
./bin/hexlint ./internal/domain/...

Enter fullscreen mode Exit fullscreen mode

Output on a violating file (one diagnostic per line, the standard go vet format):

internal/domain/order.go:5:2: domain imports forbidden package "database/sql"

Enter fullscreen mode Exit fullscreen mode

Editors that already understand go vet output will surface it inline. Drop it into CI as a separate step or wire it into a golangci-lint custom rule and it runs on every PR.

You pay for it with a binary to maintain. In return the error messages talk about your architecture, not about regex patterns.

Pick one and ship it today

If you only ship one of these, ship the bash version. Forty lines of script, one CI step, and the dependency rule stops being a vibe. You can layer go-arch-lint on top later when your boundary count grows past one. You can write a custom analyzer when you need editor-level signal.

The shape that does not work is the one most teams have right now: an architecture diagram in Confluence, a pair of senior engineers trusted to spot violations in review. And a domain package that quietly accumulates database/sql imports because the grep nobody runs would have caught them.

Make the grep run. Make it block the merge.


If this was useful

The boundary tooling is one chapter; the harder question is what your domain actually looks like once those imports are gone — what counts as a port, where DTOs live, how transactions cross the line. Hexagonal Architecture in Go walks through that end-to-end with real services, not toy examples. The companion Complete Guide to Go Programming covers the language fundamentals the architecture rests on.

If you build Go services with Claude Code or similar agents, Hermes IDE is built for that workflow.

Thinking in Go — the 2-book series on Go programming and hexagonal architecture