Use when writing generic Go, building a Go module, running gofmt, go vet or golangci-lint, handling Go security or vulnerability scanning, or framework-agnostic Go logic.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Go Dev Core?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ddtcorex-go-dev-core)
---
name: go-dev-core
description: Use when writing generic Go, building a Go module, running gofmt, go vet or golangci-lint, handling Go security or vulnerability scanning, or framework-agnostic Go logic.
compatibility: claude, codex, opencode, copilot, dsh
metadata:
audience: developers
workflow: go
---
# Go Developer Core
Structure and topic split adapted from `samber/cc-skills-golang` (MIT); packaging/publishing
and `govulncheck` coverage below are this skill's own addition, not in that source.
## When to use
Load this skill for Go work outside a specific framework (a web framework's own conventions
still get their own skill when one exists).
- "write generic Go", "create a Go module", "run gofmt", "go vet", "golangci-lint"
- "Go security", "govulncheck", "framework-agnostic Go logic"
## 1. Style and Formatting
`gofmt` is not optional, and CI must fail on unformatted code, not just warn:
```bash
gofmt -l . # lists files that would change; non-empty output = fail CI
goimports -w . # gofmt plus import grouping/pruning
```
- Package names: short, lowercase, no underscores (`httpclient`, not `http_client`).
- Exported identifiers get a doc comment starting with the identifier's own name
(`// UserService handles ...`), `golangci-lint`'s `revive`/`stylecheck` rules enforce this.
- Error values are lowercase, no trailing punctuation: `errors.New("user not found")`.
## 2. Static Analysis
`go vet` is the baseline every CI must run; `golangci-lint` is the aggregate gate:
```bash
go vet ./...
golangci-lint run ./...
```
Minimal `.golangci.yml` to start from:
```yaml
linters:
enable:
- errcheck
- govet
- staticcheck
- revive
- gosec
- unused
run:
timeout: 5m
```
`gosec` overlaps with the security baseline below; keep both, `golangci-lint` catches static
patterns, `govulncheck` (below) catches known-vulnerable dependencies, which `gosec` does not.
## 3. Error Handling
- Wrap with context, never swallow: `fmt.Errorf("fetching user %d: %w", id, err)`.
- Check every error; `errcheck` in the lint config above fails the build on an unchecked one.
- Sentinel errors via `errors.New` at package level, compared with `errors.Is`; typed errors via
a custom type, compared with `errors.As`. Never compare error strings.
- A function that always returns an error path for a given input should be structured so the
caller cannot forget to check it (return early, do not log-and-continue on a real failure).
## 4. Packaging, Modules and Versioning
- `go.mod` pins the module's own minimum Go version (`go 1.2x`) and its direct dependencies;
run `go mod tidy` before every commit that touches imports, it is not optional cleanup.
- Semver tags (`v1.2.3`) are the only versioning Go modules understand; a v2+ module path
must include `/v2` in its import path per Go's own module rules, this is not a convention,
the toolchain enforces it.
- A multi-module repo uses a `go.work` file for local development only; never commit it to a
library repo that other projects import (it is a local override, not a dependency manifest).
- Publishing a Go module is pushing the tag; there is no separate publish step like npm or
Composer, the module proxy picks it up from the tag.
## 5. Security and Vulnerability Scanning
```bash
govulncheck ./... # known vulnerabilities in the actual call graph, not just listed deps
gosec ./... # static security patterns (SQL building, weak crypto, etc.)
```
- Never build SQL by string concatenation; use `database/sql` with placeholders (`?` or `$1`)
and `QueryContext`/`ExecContext` so a cancelled request actually stops the query.
- `crypto/rand`, never `math/rand`, for anything security-sensitive (tokens, salts, nonces).
- Validate all external input at the boundary; a struct tag like `validate:"required,email"`
with a validation library is clearer than hand-rolled checks scattered through handlers.
## 6. Testing
- Table-driven tests are the Go idiom; one `t.Run(tt.name, ...)` subtest per case.
- Run with the race detector in CI, not just locally, it is cheap and catches real bugs:
```bash
go test -race -cover ./...
```
- `testing/fstest` and `httptest` for filesystem/HTTP boundaries instead of real I/O in unit
tests; reserve real I/O for an explicitly tagged integration suite (`-tags=integration`).
- Fuzzing (`go test -fuzz=FuzzXxx`) for any function parsing untrusted input (a protocol
decoder, a config parser); not required everywhere, but the first thing to add when a parser
has had a real bug.
### Verification Checklist (Run Before Every Commit)
```bash
gofmt -l . # 1. Must print nothing
go vet ./... # 2. Vet clean
golangci-lint run ./... # 3. Aggregate lint clean
govulncheck ./... # 4. No known vulnerabilities in the call graph
go test -race -cover ./... # 5. Tests green, race-clean
```