بنقرة واحدة
golang-rules
Comprehensive Go coding rules covering style, patterns, testing, and security
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Comprehensive Go coding rules covering style, patterns, testing, and security
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
| name | golang-rules |
| description | Comprehensive Go coding rules covering style, patterns, testing, and security |
ALWAYS create new objects, NEVER mutate existing ones:
// Pseudocode
WRONG: modify(original, field, value) -> changes original in-place
CORRECT: update(original, field, value) -> returns new copy with change
Rationale: Immutable data prevents hidden side effects, makes debugging easier, and enables safe concurrency.
MANY SMALL FILES > FEW LARGE FILES:
ALWAYS handle errors comprehensively:
Always wrap errors with context:
if err != nil {
return fmt.Errorf("failed to create user: %w", err)
}
ALWAYS validate at system boundaries:
Before marking work complete:
When implementing new functionality:
Encapsulate data access behind a consistent interface:
Use a consistent envelope for all API responses:
type Option func(*Server)
func WithPort(port int) Option {
return func(s *Server) { s.port = port }
}
func NewServer(opts ...Option) *Server {
s := &Server{port: 8080}
for _, opt := range opts {
opt(s)
}
return s
}
Define interfaces where they are used, not where they are implemented.
Use constructor functions to inject dependencies:
func NewUserService(repo UserRepository, logger Logger) *UserService {
return &UserService{repo: repo, logger: logger}
}
Test Types (ALL required):
MANDATORY workflow:
Use the standard go test with table-driven tests.
Always run with the -race flag:
go test -race ./...
go test -cover ./...
Before ANY commit:
apiKey := os.Getenv("OPENAI_API_KEY")
if apiKey == "" {
log.Fatal("OPENAI_API_KEY not configured")
}
gosec ./...
Always use context.Context for timeout control:
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
If security issue found:
Turn unstructured documents into validated, auditable structured data with clear schemas and edge-case handling
Verification loop for Django projects: migrations, linting, tests with coverage, security scans, and deployment readiness checks before release or PR.
Java coding standards for Spring Boot services: naming, immutability, Optional usage, streams, exceptions, generics, and project layout.
Verification loop for Spring Boot projects: build, static analysis, tests with coverage, security scans, and diff review before release or PR.
Software architecture specialist for system design, scalability, and technical decision-making. Use when planning new features, refactoring large systems, or making architectural decisions.
Build and compilation error resolution specialist. Fixes build/type errors with minimal diffs, no architectural changes. Use when build fails or type errors occur.