Solizardking/clawd-bot / .agents/skills/golang-dependency-management
golang-dependency-management
VerifiedDependency management strategies for Golang projects — go.mod management, installing/upgrading packages, Minimal Version Selection, vulnerability scanning, outdated dependency tracking, binary size analysis, Dependabot/Renovate setup, conflict resolution, and go.work workspaces. Use when adding, removing, or upgrading Go dependencies, auditing vulnerabilities, resolving version conflicts, or setting up automated dependency updates.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 9.7 KB |
| evals/evals.json | config | 11.2 KB |
| references/auditing.md | markdown | 3.4 KB |
| references/automated-updates.md | markdown | 1.8 KB |
| references/conflicts.md | markdown | 2.1 KB |
| references/versioning.md | markdown | 2.7 KB |
| references/visualization.md | markdown | 1.4 KB |
| references/workspaces.md | markdown | 1.2 KB |
references/auditing.md
View on GitHub# Auditing Dependencies
## Test-Only vs Binary Dependencies
Go's `go.mod` does **not** distinguish between test-only and production dependencies. All modules appear together, with `// indirect` marking transitive dependencies.
### What Gets Included in Your Binary
- `*_test.go` files are **never** compiled by `go build` — only by `go test`
- Packages imported only by test files are not linked into the final binary
- However, their modules still appear in `go.mod`
### Module Graph Pruning (Go 1.17+)
With `go 1.17` or higher in `go.mod`, Go prunes the module graph: transitive dependencies needed only for tests of other modules are excluded from the build graph. This reduces `go.mod` size and avoids downloading unnecessary modules.
### Upgrading With or Without Test Dependencies
```bash
go get -u ./... # Upgrade deps, EXCLUDING test-only deps
go get -u -t ./... # Upgrade deps, INCLUDING test-only deps
```
### Impact on Binary Size
To check whether a large dependency is actually linked into your binary (vs. only used in tests), use `goweight` or `go-size-analyzer` — if the package doesn't appear in the binary breakdown, it's test-only and not contributing to binary size.
## Vulnerability Scanning with govulncheck
`govulncheck` reports known vulnerabilities that affect your code. It uses static analysis to narrow reports to vulnerabilities in code paths your project actually calls — unlike generic CVE scanners that flag every dependency regardless of usage.
```bash
# Scan source code (most common)
govulncheck ./...
# Or, when govulncheck is pinned with a Go 1.24+ tool directive:
go tool govulncheck ./...
# Scan a compiled binary
govulncheck -mode=binary ./bin/myapp
# JSON output (for CI integration)
govulncheck -format json ./...
# Include test code in analysis
govulncheck -test ./...
```
Output shows the vulnerability ID, affected module, fixed version, and the call trace from your code to the vulnerable function. If a vulnerability exists in a dependency but your code never calls the affected function, `govulncheck` does not flag it.
For CI pipeline integration, see the `samber/cc-skills-golang@golang-continuous-integration` skill.
## Tracking Outdated Dependencies with go-mod-outdated
`psampaz/go-mod-outdated` lists outdated direct dependencies with available updates.
```bash
# Show outdated direct dependencies with available updates
go list -u -m -json all | go-mod-outdated -update -direct
# Fail in CI if dependencies are outdated
go list -u -m -json all | go-mod-outdated -update -direct -ci
# Markdown output
go list -u -m -json all | go-mod-outdated -update -direct -style markdown
```
Output columns: MODULE, CURRENT version, WANTED (latest minor/patch), LATEST (latest overall), and VALID TIMESTAMPS (warns if an "update" is chronologically older than current).
## Analyzing Dependency Size with goweight
`jondot/goweight` lists every package linked into the binary sorted by size contribution. It helps identify bloated dependencies and evaluate whether a lighter alternative exists.
```bash
goweight # Sort by size
goweight --json # JSON output for CI tracking
```
**Modern alternative**: [go-size-analyzer](https://github.com/Zxilly/go-size-analyzer) (`gsa`) supports ELF, Mach-O, PE, and WebAssembly formats with interactive HTML/SVG visualization:
```bash
go get -tool github.com/Zxilly/go-size-analyzer/cmd/gsa@latest
go build -o ./myapp ./cmd/myapp
go tool gsa -f html -o size-report.html ./myapp
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |