mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-03-30 13:43:26 +08:00
35 lines
642 B
Markdown
35 lines
642 B
Markdown
---
|
|
description: "Go security: environment variable secrets, gosec static analysis, context timeouts"
|
|
globs: ["**/*.go"]
|
|
alwaysApply: false
|
|
---
|
|
|
|
# Go Security
|
|
|
|
> This file extends [common/security.md](../common/security.md) with Go specific content.
|
|
|
|
## Secret Management
|
|
|
|
```go
|
|
apiKey := os.Getenv("OPENAI_API_KEY")
|
|
if apiKey == "" {
|
|
log.Fatal("OPENAI_API_KEY not configured")
|
|
}
|
|
```
|
|
|
|
## Security Scanning
|
|
|
|
- Use **gosec** for static security analysis:
|
|
```bash
|
|
gosec ./...
|
|
```
|
|
|
|
## Context & Timeouts
|
|
|
|
Always use `context.Context` for timeout control:
|
|
|
|
```go
|
|
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
|
defer cancel()
|
|
```
|