xiaohongshu
xiaohongshu
go-pro
Expert Go developer specializing in idiomatic patterns, concurrency, error handling, and clean package design. This skill should be used PROACTIVELY when working on any Go code - implementing features, designing APIs, debugging issues, or reviewing code quality. Use unless a more specific subagen...
Full skill instructions
Senior-level Go expertise for production projects. Focuses on idiomatic patterns, simplicity, and Go's design philosophy.
go.mod and .golangci.yml for project conventionsNon-Negotiable:
_ = err)panic() for recoverable errorsFoundational Principles:
mise manages language runtimes per-project. Ensures all contributors use the same Go version—no "works on my machine" issues.
# Install mise (once)
curl https://mise.run | sh
# In project root
mise use [email protected]
# Creates .mise.toml — commit it
# Team members just run: mise install
# Initialize
go mod init github.com/org/project
go mod edit -go=1.25
# Add toolchain dependencies (tracked in go.mod)
go get -tool github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
go get -tool golang.org/x/tools/cmd/goimports@latest
# Copy configs from this skill's references/ directory:
# references/gitignore → .gitignore
# references/golangci-v2.yml → .golangci.yml
# For build system, invoke just-pro skill
# Verify
just check # Or: go tool golangci-lint run
git clone <repo> && cd <repo>
just setup # Runs mise trust/install + go mod download
just check # Verify everything works
Or manually:
mise trust && mise install # Get pinned Go version
go mod download # Get dependencies
Why go get -tool? Tools versioned in go.mod = reproducible builds, same versions for all devs, no separate installation needed.
Invoke the just-pro skill for build system setup. It covers:
references/package-go.just)Why just? Consistent toolchain frontend between agents and humans. Instead of remembering go tool golangci-lint run --fix, use just fix.
Auto-Fix First - Always try auto-fix before manual fixes:
just fix # Or: go tool golangci-lint run --fix && go tool goimports -w .
Verification:
just check # Or: go tool golangci-lint run && go test -race ./...
| Pattern | Use |
|---|---|
return err | Propagate unchanged (internal errors) |
fmt.Errorf("context: %w", err) | Wrap with context (cross-boundary) |
errors.Is(err, target) | Check specific error |
errors.As(err, &target) | Extract typed error |
Sentinel Errors - Define package-level errors for expected conditions:
var ErrNotFound = errors.New("not found")
var ErrInvalidInput = errors.New("invalid input")
// Constrained generics - prefer specific constraints
func Map[T, U any](items []T, fn func(T) U) []U {
result := make([]U, len(items))
for i, item := range items {
result[i] = fn(item)
}
return result
}
// Type constraints - use interfaces
type Ordered interface {
~int | ~int64 | ~float64 | ~string
}
func Max[T Ordered](a, b T) T {
if a > b {
return a
}
return b
}
// Avoid: overly generic signatures that lose type safety
// Prefer: concrete types until generics are clearly needed
import "log/slog"
// Package-level logger with context
func NewService(logger *slog.Logger) *Service {
return &Service{
log: logger.With("component", "service"),
}
}
// Structured logging with levels
s.log.Info("request processed",
"method", r.Method,
"path", r.URL.Path,
"duration", time.Since(start),
)
s.log.Error("operation failed",
"err", err,
"user_id", userID,
)
import "iter"
// Return iterators for large collections
func (db *DB) Users() iter.Seq[User] {
return func(yield func(User) bool) {
rows, _ := db.Query("SELECT * FROM users")
defer rows.Close()
for rows.Next() {
var u User
rows.Scan(&u.ID, &u.Name)
if !yield(u) {
return
}
}
}
}
// Consume with range
for user := range db.Users() {
process(user)
}
// Seq2 for key-value pairs
func (m *Map[K, V]) All() iter.Seq2[K, V]
| Pattern | Use |
|---|---|
sync.WaitGroup | Wait for goroutines |
sync.Mutex / RWMutex | Protect shared state |
context.Context | Cancellation/timeouts |
errgroup.Group | Concurrent with error collection |
// Context-aware work
func DoWork(ctx context.Context, arg string) error {
select {
case <-ctx.Done():
return ctx.Err()
default:
}
// ... work
}
// Table-driven tests with subtests
func TestParse(t *testing.T) {
tests := []struct {
name string
input string
want Result
wantErr bool
}{
{name: "valid", input: "foo", want: Result{Value: "foo"}},
{name: "empty", input: "", wantErr: true},
{name: "special", input: "a@b", want: Result{Value: "a@b"}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := Parse(tt.input)
if (err != nil) != tt.wantErr {
t.Errorf("Parse() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("Parse() = %v, want %v", got, tt.want)
}
})
}
}
// Testify for complex assertions
import "github.com/stretchr/testify/assert"
import "github.com/stretchr/testify/require"
func TestService(t *testing.T) {
require.NoError(t, err) // Fail fast
assert.Equal(t, expected, actual) // Continue on failure
assert.Len(t, items, 3)
assert.Contains(t, items, target)
}
// Use pointer receivers when:
// - Method modifies the receiver
// - Receiver is large (avoid copy)
// - Consistency: if any method needs pointer, use pointer for all
func (s *Service) UpdateConfig(cfg Config) { s.cfg = cfg }
// Use value receivers when:
// - Receiver is small (int, string, small struct)
// - Method is read-only and receiver is immutable
func (p Point) Distance(other Point) float64 { ... }
project/
├── cmd/appname/main.go # Entry point
├── internal/ # Private packages
│ ├── api/ # Handlers
│ └── domain/ # Business logic
├── go.mod
├── .golangci.yml
└── justfile
Rules: One package = one purpose. Use internal/ for implementation. Avoid util, common, helpers packages.
Doctor scripts should validate that toolchain versions meet requirements, not just check existence:
# Validate toolchain versions meet requirements
doctor:
#!/usr/bin/env bash
set -euo pipefail
echo "Checking toolchain..."
# Validate Go version (requires 1.25+)
GO_VERSION=$(go version | grep -oE 'go[0-9]+\.[0-9]+' | sed 's/go//')
if [[ "$(printf '%s\n' "1.25" "$GO_VERSION" | sort -V | head -1)" != "1.25" ]]; then
echo "FAIL: Go $GO_VERSION < 1.25 required"
exit 1
fi
echo "✓ Go $GO_VERSION"
# Add more version checks as needed
echo "All checks passed"
For services that bind ports, check availability before starting:
# Check if required ports are available before starting
check-ports:
#!/usr/bin/env bash
for port in 8080 5432; do
if lsof -i :$port >/dev/null 2>&1; then
echo "FAIL: Port $port already in use"
exit 1
fi
done
echo "All ports available"
Avoid redundant setup work with first-run detection:
# Setup with first-run detection
setup:
#!/usr/bin/env bash
if [[ -f .setup-complete ]]; then
echo "Already set up. Run 'just setup-force' to reinstall."
exit 0
fi
mise trust && mise install
go mod download
touch .setup-complete
echo "Setup complete"
setup-force:
rm -f .setup-complete
@just setup
panic() for recoverable errors (use return err)_init() with side effectsinterface{} or any when specific types workBefore writing code:
go.mod for module path and Go version.golangci.yml for project-specific lint rulesWhen writing code:
_ = errBefore committing:
just check (standard for projects using just)go tool golangci-lint run --fix && go tool golangci-lint rungo test -race ./... to catch race conditionsxiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience