@mytechtoday/augment-extensions 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/augment-extensions/coding-standards/c/CHANGELOG.md +55 -0
- package/augment-extensions/coding-standards/c/LICENSE +22 -0
- package/augment-extensions/coding-standards/c/README.md +167 -0
- package/augment-extensions/coding-standards/c/config/defaults.json +26 -0
- package/augment-extensions/coding-standards/c/config/examples/embedded.yaml +25 -0
- package/augment-extensions/coding-standards/c/config/examples/systems.json +31 -0
- package/augment-extensions/coding-standards/c/config/schema.json +244 -0
- package/augment-extensions/coding-standards/c/docs/API.md +613 -0
- package/augment-extensions/coding-standards/c/docs/CONFIGURATION.md +259 -0
- package/augment-extensions/coding-standards/c/docs/USER_GUIDE.md +567 -0
- package/augment-extensions/coding-standards/c/examples/drivers/Makefile +33 -0
- package/augment-extensions/coding-standards/c/examples/drivers/README.md +192 -0
- package/augment-extensions/coding-standards/c/examples/drivers/dma-example.c +224 -0
- package/augment-extensions/coding-standards/c/examples/drivers/example.dts +64 -0
- package/augment-extensions/coding-standards/c/examples/drivers/platform-driver.c +174 -0
- package/augment-extensions/coding-standards/c/examples/embedded/README.md +167 -0
- package/augment-extensions/coding-standards/c/examples/embedded/gpio-control.c +172 -0
- package/augment-extensions/coding-standards/c/examples/embedded/timer-isr.c +198 -0
- package/augment-extensions/coding-standards/c/examples/embedded/uart-communication.c +212 -0
- package/augment-extensions/coding-standards/c/examples/kernel/Makefile +82 -0
- package/augment-extensions/coding-standards/c/examples/kernel/README.md +168 -0
- package/augment-extensions/coding-standards/c/examples/kernel/char-device.c +198 -0
- package/augment-extensions/coding-standards/c/examples/kernel/proc-file.c +131 -0
- package/augment-extensions/coding-standards/c/examples/kernel/simple-module.c +111 -0
- package/augment-extensions/coding-standards/c/examples/legacy/Makefile +62 -0
- package/augment-extensions/coding-standards/c/examples/legacy/README.md +255 -0
- package/augment-extensions/coding-standards/c/examples/legacy/c89-to-c11-migration.c +268 -0
- package/augment-extensions/coding-standards/c/examples/legacy/compatibility-layer.c +239 -0
- package/augment-extensions/coding-standards/c/examples/networking/Makefile +35 -0
- package/augment-extensions/coding-standards/c/examples/networking/README.md +207 -0
- package/augment-extensions/coding-standards/c/examples/networking/protocol-parser.c +270 -0
- package/augment-extensions/coding-standards/c/examples/networking/tcp-server.c +197 -0
- package/augment-extensions/coding-standards/c/examples/networking/udp-multicast.c +220 -0
- package/augment-extensions/coding-standards/c/examples/realtime/Makefile +53 -0
- package/augment-extensions/coding-standards/c/examples/realtime/README.md +199 -0
- package/augment-extensions/coding-standards/c/examples/realtime/deadline-monitoring.c +260 -0
- package/augment-extensions/coding-standards/c/examples/realtime/priority-scheduling.c +258 -0
- package/augment-extensions/coding-standards/c/examples/systems/Makefile +34 -0
- package/augment-extensions/coding-standards/c/examples/systems/README.md +123 -0
- package/augment-extensions/coding-standards/c/examples/systems/ipc-pipes.c +181 -0
- package/augment-extensions/coding-standards/c/examples/systems/process-management.c +153 -0
- package/augment-extensions/coding-standards/c/examples/systems/signal-handling.c +162 -0
- package/augment-extensions/coding-standards/c/module.json +149 -0
- package/augment-extensions/coding-standards/c/rules/categories/drivers.md +635 -0
- package/augment-extensions/coding-standards/c/rules/categories/embedded.md +510 -0
- package/augment-extensions/coding-standards/c/rules/categories/kernel.md +653 -0
- package/augment-extensions/coding-standards/c/rules/categories/legacy.md +526 -0
- package/augment-extensions/coding-standards/c/rules/categories/networking.md +735 -0
- package/augment-extensions/coding-standards/c/rules/categories/realtime.md +631 -0
- package/augment-extensions/coding-standards/c/rules/categories/systems.md +586 -0
- package/augment-extensions/coding-standards/c/rules/universal/const-correctness.md +275 -0
- package/augment-extensions/coding-standards/c/rules/universal/documentation.md +251 -0
- package/augment-extensions/coding-standards/c/rules/universal/error-handling.md +250 -0
- package/augment-extensions/coding-standards/c/rules/universal/header-guards.md +254 -0
- package/augment-extensions/coding-standards/c/rules/universal/memory-safety.md +233 -0
- package/augment-extensions/coding-standards/c/rules/universal/naming.md +146 -0
- package/augment-extensions/coding-standards/c/src/conflict-detector.ts +461 -0
- package/augment-extensions/coding-standards/c/src/prompt-generator.ts +307 -0
- package/augment-extensions/coding-standards/c/src/rule-evaluator.ts +307 -0
- package/augment-extensions/coding-standards/c/src/rule-override.ts +427 -0
- package/augment-extensions/coding-standards/c/src/template-engine.ts +217 -0
- package/augment-extensions/coding-standards/c/templates/prompts/drivers.txt +191 -0
- package/augment-extensions/coding-standards/c/templates/prompts/embedded.txt +164 -0
- package/augment-extensions/coding-standards/c/templates/prompts/kernel.txt +175 -0
- package/augment-extensions/coding-standards/c/templates/prompts/legacy.txt +280 -0
- package/augment-extensions/coding-standards/c/templates/prompts/networking.txt +259 -0
- package/augment-extensions/coding-standards/c/templates/prompts/realtime.txt +219 -0
- package/augment-extensions/coding-standards/c/templates/prompts/systems.txt +147 -0
- package/augment-extensions/coding-standards/c/tests/integration/category-specific.test.ts +356 -0
- package/augment-extensions/coding-standards/c/tests/integration/end-to-end-workflow.test.ts +377 -0
- package/augment-extensions/coding-standards/c/tests/performance/benchmarks.test.ts +407 -0
- package/augment-extensions/coding-standards/c/tests/unit/config-manager.test.ts +345 -0
- package/augment-extensions/coding-standards/c/tests/unit/conflict-detector.test.ts +294 -0
- package/augment-extensions/coding-standards/c/tests/unit/prompt-generator.test.ts +174 -0
- package/augment-extensions/coding-standards/c/tests/unit/registry.test.ts +313 -0
- package/augment-extensions/coding-standards/c/tests/unit/rule-evaluator.test.ts +318 -0
- package/augment-extensions/coding-standards/c/tests/unit/rule-override.test.ts +326 -0
- package/augment-extensions/coding-standards/c/tests/unit/template-engine.test.ts +314 -0
- package/augment-extensions/coding-standards/go/CHARACTER-COUNT-REPORT.md +135 -0
- package/augment-extensions/coding-standards/go/PHASE1-COMPLETION.md +146 -0
- package/augment-extensions/coding-standards/go/PHASE4-COMPLETION.md +184 -0
- package/augment-extensions/coding-standards/go/README.md +200 -0
- package/augment-extensions/coding-standards/go/VALIDATION-CHECKLIST.md +154 -0
- package/augment-extensions/coding-standards/go/config/examples/example-cli.json +15 -0
- package/augment-extensions/coding-standards/go/config/examples/example-microservices.json +21 -0
- package/augment-extensions/coding-standards/go/config/examples/example-multi-category.yaml +24 -0
- package/augment-extensions/coding-standards/go/config/examples/example-web.json +15 -0
- package/augment-extensions/coding-standards/go/config/schema.json +110 -0
- package/augment-extensions/coding-standards/go/docs/CATEGORIES.md +221 -0
- package/augment-extensions/coding-standards/go/docs/CONFIGURATION.md +198 -0
- package/augment-extensions/coding-standards/go/docs/TROUBLESHOOTING.md +285 -0
- package/augment-extensions/coding-standards/go/examples/cli/cobra-app.go +287 -0
- package/augment-extensions/coding-standards/go/examples/cloud-native-app.go +217 -0
- package/augment-extensions/coding-standards/go/examples/devops-tool.go +250 -0
- package/augment-extensions/coding-standards/go/examples/distributed-system.go +247 -0
- package/augment-extensions/coding-standards/go/examples/microservices/grpc-service.go +253 -0
- package/augment-extensions/coding-standards/go/examples/rest-api.go +270 -0
- package/augment-extensions/coding-standards/go/examples/web/http-server.go +224 -0
- package/augment-extensions/coding-standards/go/module.json +139 -0
- package/augment-extensions/coding-standards/go/rules/categories/api-development/api-versioning.md +149 -0
- package/augment-extensions/coding-standards/go/rules/categories/api-development/rate-limiting.md +209 -0
- package/augment-extensions/coding-standards/go/rules/categories/api-development/rest-api-design.md +183 -0
- package/augment-extensions/coding-standards/go/rules/categories/cloud-native/cloud-config.md +193 -0
- package/augment-extensions/coding-standards/go/rules/categories/cloud-native/health-checks.md +231 -0
- package/augment-extensions/coding-standards/go/rules/categories/cloud-native/kubernetes.md +180 -0
- package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/automation.md +179 -0
- package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/ci-cd-integration.md +147 -0
- package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/infrastructure-as-code.md +231 -0
- package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/caching.md +150 -0
- package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/consensus.md +187 -0
- package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/event-sourcing.md +246 -0
- package/augment-extensions/coding-standards/go/rules/cli/command-parsing.md +264 -0
- package/augment-extensions/coding-standards/go/rules/cli/configuration.md +268 -0
- package/augment-extensions/coding-standards/go/rules/cli/cross-platform.md +324 -0
- package/augment-extensions/coding-standards/go/rules/microservices/distributed-tracing.md +253 -0
- package/augment-extensions/coding-standards/go/rules/microservices/grpc.md +257 -0
- package/augment-extensions/coding-standards/go/rules/microservices/metrics.md +278 -0
- package/augment-extensions/coding-standards/go/rules/microservices/service-discovery.md +249 -0
- package/augment-extensions/coding-standards/go/rules/universal/code-organization.md +221 -0
- package/augment-extensions/coding-standards/go/rules/universal/documentation.md +269 -0
- package/augment-extensions/coding-standards/go/rules/universal/performance.md +323 -0
- package/augment-extensions/coding-standards/go/rules/universal/testing.md +162 -0
- package/augment-extensions/coding-standards/go/rules/web/graceful-shutdown.md +249 -0
- package/augment-extensions/coding-standards/go/rules/web/http-handlers.md +164 -0
- package/augment-extensions/coding-standards/go/rules/web/middleware.md +234 -0
- package/augment-extensions/coding-standards/go/rules/web/routing.md +251 -0
- package/augment-extensions/coding-standards/go/templates/prompts/api.md +160 -0
- package/augment-extensions/coding-standards/go/templates/prompts/cli.md +225 -0
- package/augment-extensions/coding-standards/go/templates/prompts/cloud-native.md +121 -0
- package/augment-extensions/coding-standards/go/templates/prompts/devops.md +146 -0
- package/augment-extensions/coding-standards/go/templates/prompts/distributed.md +133 -0
- package/augment-extensions/coding-standards/go/templates/prompts/microservices.md +225 -0
- package/augment-extensions/coding-standards/go/templates/prompts/web.md +181 -0
- package/augment-extensions/coding-standards/go/tests/integration/module-integration.test.ts +164 -0
- package/augment-extensions/coding-standards/go/tests/unit/category-selection.test.ts +147 -0
- package/augment-extensions/coding-standards/go/tests/unit/module-structure.test.ts +154 -0
- package/augment-extensions/coding-standards/go/tests/validate-character-count.ps1 +13 -0
- package/augment-extensions/coding-standards/go/tests/validate-examples.ps1 +148 -0
- package/augment-extensions/coding-standards/go/tests/validate-examples.sh +135 -0
- package/cli/dist/analysis/ast-parser.d.ts +47 -0
- package/cli/dist/analysis/ast-parser.d.ts.map +1 -0
- package/cli/dist/analysis/ast-parser.js +161 -0
- package/cli/dist/analysis/ast-parser.js.map +1 -0
- package/cli/dist/analysis/complexity-analyzer.d.ts +27 -0
- package/cli/dist/analysis/complexity-analyzer.d.ts.map +1 -0
- package/cli/dist/analysis/complexity-analyzer.js +189 -0
- package/cli/dist/analysis/complexity-analyzer.js.map +1 -0
- package/cli/dist/analysis/dependency-analyzer.d.ts +23 -0
- package/cli/dist/analysis/dependency-analyzer.d.ts.map +1 -0
- package/cli/dist/analysis/dependency-analyzer.js +237 -0
- package/cli/dist/analysis/dependency-analyzer.js.map +1 -0
- package/cli/dist/analysis/index.d.ts +9 -0
- package/cli/dist/analysis/index.d.ts.map +1 -0
- package/cli/dist/analysis/index.js +25 -0
- package/cli/dist/analysis/index.js.map +1 -0
- package/cli/dist/analysis/security-scanner.d.ts +11 -0
- package/cli/dist/analysis/security-scanner.d.ts.map +1 -0
- package/cli/dist/analysis/security-scanner.js +294 -0
- package/cli/dist/analysis/security-scanner.js.map +1 -0
- package/cli/dist/analysis/types.d.ts +151 -0
- package/cli/dist/analysis/types.d.ts.map +1 -0
- package/cli/dist/analysis/types.js +6 -0
- package/cli/dist/analysis/types.js.map +1 -0
- package/cli/dist/cli.js +24 -0
- package/cli/dist/cli.js.map +1 -1
- package/cli/dist/commands/code-analysis.d.ts +11 -0
- package/cli/dist/commands/code-analysis.d.ts.map +1 -0
- package/cli/dist/commands/code-analysis.js +412 -0
- package/cli/dist/commands/code-analysis.js.map +1 -0
- package/modules.md +99 -3
- package/package.json +14 -2
- package/cli/dist/commands/agent.d.ts +0 -37
- package/cli/dist/commands/agent.d.ts.map +0 -1
- package/cli/dist/commands/agent.js +0 -222
- package/cli/dist/commands/agent.js.map +0 -1
- package/cli/dist/commands/beads.d.ts +0 -64
- package/cli/dist/commands/beads.d.ts.map +0 -1
- package/cli/dist/commands/beads.js +0 -377
- package/cli/dist/commands/beads.js.map +0 -1
- package/cli/dist/commands/change.d.ts +0 -54
- package/cli/dist/commands/change.d.ts.map +0 -1
- package/cli/dist/commands/change.js +0 -243
- package/cli/dist/commands/change.js.map +0 -1
- package/cli/dist/commands/clean.d.ts +0 -15
- package/cli/dist/commands/clean.d.ts.map +0 -1
- package/cli/dist/commands/clean.js +0 -63
- package/cli/dist/commands/clean.js.map +0 -1
- package/cli/dist/commands/clone.d.ts +0 -15
- package/cli/dist/commands/clone.d.ts.map +0 -1
- package/cli/dist/commands/clone.js +0 -49
- package/cli/dist/commands/clone.js.map +0 -1
- package/cli/dist/commands/config.d.ts +0 -33
- package/cli/dist/commands/config.d.ts.map +0 -1
- package/cli/dist/commands/config.js +0 -166
- package/cli/dist/commands/config.js.map +0 -1
- package/cli/dist/commands/context.d.ts +0 -38
- package/cli/dist/commands/context.d.ts.map +0 -1
- package/cli/dist/commands/context.js +0 -205
- package/cli/dist/commands/context.js.map +0 -1
- package/cli/dist/commands/create.d.ts +0 -18
- package/cli/dist/commands/create.d.ts.map +0 -1
- package/cli/dist/commands/create.js +0 -178
- package/cli/dist/commands/create.js.map +0 -1
- package/cli/dist/commands/diff.d.ts +0 -19
- package/cli/dist/commands/diff.d.ts.map +0 -1
- package/cli/dist/commands/diff.js +0 -104
- package/cli/dist/commands/diff.js.map +0 -1
- package/cli/dist/commands/doctor.d.ts +0 -14
- package/cli/dist/commands/doctor.d.ts.map +0 -1
- package/cli/dist/commands/doctor.js +0 -62
- package/cli/dist/commands/doctor.js.map +0 -1
- package/cli/dist/commands/export.d.ts +0 -28
- package/cli/dist/commands/export.d.ts.map +0 -1
- package/cli/dist/commands/export.js +0 -135
- package/cli/dist/commands/export.js.map +0 -1
- package/cli/dist/commands/import.d.ts +0 -23
- package/cli/dist/commands/import.d.ts.map +0 -1
- package/cli/dist/commands/import.js +0 -118
- package/cli/dist/commands/import.js.map +0 -1
- package/cli/dist/commands/prompt.d.ts +0 -45
- package/cli/dist/commands/prompt.d.ts.map +0 -1
- package/cli/dist/commands/prompt.js +0 -223
- package/cli/dist/commands/prompt.js.map +0 -1
- package/cli/dist/commands/spec.d.ts +0 -57
- package/cli/dist/commands/spec.d.ts.map +0 -1
- package/cli/dist/commands/spec.js +0 -279
- package/cli/dist/commands/spec.js.map +0 -1
- package/cli/dist/commands/stats.d.ts +0 -18
- package/cli/dist/commands/stats.d.ts.map +0 -1
- package/cli/dist/commands/stats.js +0 -85
- package/cli/dist/commands/stats.js.map +0 -1
- package/cli/dist/commands/task.d.ts +0 -65
- package/cli/dist/commands/task.d.ts.map +0 -1
- package/cli/dist/commands/task.js +0 -282
- package/cli/dist/commands/task.js.map +0 -1
- package/cli/dist/commands/template.d.ts +0 -17
- package/cli/dist/commands/template.d.ts.map +0 -1
- package/cli/dist/commands/template.js +0 -55
- package/cli/dist/commands/template.js.map +0 -1
- package/cli/dist/utils/agent-config.d.ts +0 -129
- package/cli/dist/utils/agent-config.d.ts.map +0 -1
- package/cli/dist/utils/agent-config.js +0 -297
- package/cli/dist/utils/agent-config.js.map +0 -1
- package/cli/dist/utils/beads-graph.d.ts +0 -17
- package/cli/dist/utils/beads-graph.d.ts.map +0 -1
- package/cli/dist/utils/beads-graph.js +0 -150
- package/cli/dist/utils/beads-graph.js.map +0 -1
- package/cli/dist/utils/beads-integration.d.ts +0 -112
- package/cli/dist/utils/beads-integration.d.ts.map +0 -1
- package/cli/dist/utils/beads-integration.js +0 -312
- package/cli/dist/utils/beads-integration.js.map +0 -1
- package/cli/dist/utils/beads-reporter.d.ts +0 -17
- package/cli/dist/utils/beads-reporter.d.ts.map +0 -1
- package/cli/dist/utils/beads-reporter.js +0 -160
- package/cli/dist/utils/beads-reporter.js.map +0 -1
- package/cli/dist/utils/cache-manager.d.ts +0 -55
- package/cli/dist/utils/cache-manager.d.ts.map +0 -1
- package/cli/dist/utils/cache-manager.js +0 -150
- package/cli/dist/utils/cache-manager.js.map +0 -1
- package/cli/dist/utils/change-manager.d.ts +0 -70
- package/cli/dist/utils/change-manager.d.ts.map +0 -1
- package/cli/dist/utils/change-manager.js +0 -412
- package/cli/dist/utils/change-manager.js.map +0 -1
- package/cli/dist/utils/config-manager-enhanced.d.ts +0 -66
- package/cli/dist/utils/config-manager-enhanced.d.ts.map +0 -1
- package/cli/dist/utils/config-manager-enhanced.js +0 -77
- package/cli/dist/utils/config-manager-enhanced.js.map +0 -1
- package/cli/dist/utils/context-manager.d.ts +0 -96
- package/cli/dist/utils/context-manager.d.ts.map +0 -1
- package/cli/dist/utils/context-manager.js +0 -258
- package/cli/dist/utils/context-manager.js.map +0 -1
- package/cli/dist/utils/diff-engine.d.ts +0 -78
- package/cli/dist/utils/diff-engine.d.ts.map +0 -1
- package/cli/dist/utils/diff-engine.js +0 -233
- package/cli/dist/utils/diff-engine.js.map +0 -1
- package/cli/dist/utils/export-system.d.ts +0 -101
- package/cli/dist/utils/export-system.d.ts.map +0 -1
- package/cli/dist/utils/export-system.js +0 -289
- package/cli/dist/utils/export-system.js.map +0 -1
- package/cli/dist/utils/health-checker.d.ts +0 -66
- package/cli/dist/utils/health-checker.d.ts.map +0 -1
- package/cli/dist/utils/health-checker.js +0 -285
- package/cli/dist/utils/health-checker.js.map +0 -1
- package/cli/dist/utils/import-system.d.ts +0 -74
- package/cli/dist/utils/import-system.d.ts.map +0 -1
- package/cli/dist/utils/import-system.js +0 -317
- package/cli/dist/utils/import-system.js.map +0 -1
- package/cli/dist/utils/module-cloner.d.ts +0 -40
- package/cli/dist/utils/module-cloner.d.ts.map +0 -1
- package/cli/dist/utils/module-cloner.js +0 -136
- package/cli/dist/utils/module-cloner.js.map +0 -1
- package/cli/dist/utils/prompt-manager.d.ts +0 -90
- package/cli/dist/utils/prompt-manager.d.ts.map +0 -1
- package/cli/dist/utils/prompt-manager.js +0 -302
- package/cli/dist/utils/prompt-manager.js.map +0 -1
- package/cli/dist/utils/spec-manager.d.ts +0 -65
- package/cli/dist/utils/spec-manager.d.ts.map +0 -1
- package/cli/dist/utils/spec-manager.js +0 -329
- package/cli/dist/utils/spec-manager.js.map +0 -1
- package/cli/dist/utils/stats-collector.d.ts +0 -74
- package/cli/dist/utils/stats-collector.d.ts.map +0 -1
- package/cli/dist/utils/stats-collector.js +0 -164
- package/cli/dist/utils/stats-collector.js.map +0 -1
- package/cli/dist/utils/template-engine.d.ts +0 -47
- package/cli/dist/utils/template-engine.d.ts.map +0 -1
- package/cli/dist/utils/template-engine.js +0 -204
- package/cli/dist/utils/template-engine.js.map +0 -1
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
// Package main demonstrates a production-ready HTTP server with best practices
|
|
2
|
+
package main
|
|
3
|
+
|
|
4
|
+
import (
|
|
5
|
+
"context"
|
|
6
|
+
"encoding/json"
|
|
7
|
+
"errors"
|
|
8
|
+
"log/slog"
|
|
9
|
+
"net/http"
|
|
10
|
+
"os"
|
|
11
|
+
"os/signal"
|
|
12
|
+
"strconv"
|
|
13
|
+
"syscall"
|
|
14
|
+
"time"
|
|
15
|
+
|
|
16
|
+
"github.com/go-chi/chi/v5"
|
|
17
|
+
"github.com/go-chi/chi/v5/middleware"
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
// User represents a user in the system
|
|
21
|
+
type User struct {
|
|
22
|
+
ID int64 `json:"id"`
|
|
23
|
+
Name string `json:"name"`
|
|
24
|
+
Email string `json:"email"`
|
|
25
|
+
CreatedAt time.Time `json:"created_at"`
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// UserService handles user operations
|
|
29
|
+
type UserService struct {
|
|
30
|
+
logger *slog.Logger
|
|
31
|
+
users map[int64]*User // In-memory store for demo
|
|
32
|
+
nextID int64
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// NewUserService creates a new user service
|
|
36
|
+
func NewUserService(logger *slog.Logger) *UserService {
|
|
37
|
+
return &UserService{
|
|
38
|
+
logger: logger,
|
|
39
|
+
users: make(map[int64]*User),
|
|
40
|
+
nextID: 1,
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// GetUser retrieves a user by ID
|
|
45
|
+
func (s *UserService) GetUser(ctx context.Context, id int64) (*User, error) {
|
|
46
|
+
user, ok := s.users[id]
|
|
47
|
+
if !ok {
|
|
48
|
+
return nil, errors.New("user not found")
|
|
49
|
+
}
|
|
50
|
+
return user, nil
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// CreateUser creates a new user
|
|
54
|
+
func (s *UserService) CreateUser(ctx context.Context, name, email string) (*User, error) {
|
|
55
|
+
user := &User{
|
|
56
|
+
ID: s.nextID,
|
|
57
|
+
Name: name,
|
|
58
|
+
Email: email,
|
|
59
|
+
CreatedAt: time.Now(),
|
|
60
|
+
}
|
|
61
|
+
s.users[s.nextID] = user
|
|
62
|
+
s.nextID++
|
|
63
|
+
return user, nil
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Server represents the HTTP server
|
|
67
|
+
type Server struct {
|
|
68
|
+
http *http.Server
|
|
69
|
+
userService *UserService
|
|
70
|
+
logger *slog.Logger
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// NewServer creates a new HTTP server
|
|
74
|
+
func NewServer(addr string, logger *slog.Logger) *Server {
|
|
75
|
+
userService := NewUserService(logger)
|
|
76
|
+
|
|
77
|
+
s := &Server{
|
|
78
|
+
userService: userService,
|
|
79
|
+
logger: logger,
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
s.http = &http.Server{
|
|
83
|
+
Addr: addr,
|
|
84
|
+
Handler: s.routes(),
|
|
85
|
+
ReadTimeout: 15 * time.Second,
|
|
86
|
+
WriteTimeout: 15 * time.Second,
|
|
87
|
+
IdleTimeout: 60 * time.Second,
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return s
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// routes sets up the HTTP routes
|
|
94
|
+
func (s *Server) routes() http.Handler {
|
|
95
|
+
r := chi.NewRouter()
|
|
96
|
+
|
|
97
|
+
// Middleware
|
|
98
|
+
r.Use(middleware.RequestID)
|
|
99
|
+
r.Use(middleware.RealIP)
|
|
100
|
+
r.Use(middleware.Logger)
|
|
101
|
+
r.Use(middleware.Recoverer)
|
|
102
|
+
r.Use(middleware.Timeout(30 * time.Second))
|
|
103
|
+
|
|
104
|
+
// Health check
|
|
105
|
+
r.Get("/health", s.handleHealth)
|
|
106
|
+
|
|
107
|
+
// API routes
|
|
108
|
+
r.Route("/api/v1", func(r chi.Router) {
|
|
109
|
+
r.Route("/users", func(r chi.Router) {
|
|
110
|
+
r.Get("/{id}", s.handleGetUser)
|
|
111
|
+
r.Post("/", s.handleCreateUser)
|
|
112
|
+
})
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
return r
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// handleHealth handles health check requests
|
|
119
|
+
func (s *Server) handleHealth(w http.ResponseWriter, r *http.Request) {
|
|
120
|
+
w.WriteHeader(http.StatusOK)
|
|
121
|
+
json.NewEncoder(w).Encode(map[string]string{"status": "healthy"})
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// handleGetUser handles GET /api/v1/users/{id}
|
|
125
|
+
func (s *Server) handleGetUser(w http.ResponseWriter, r *http.Request) {
|
|
126
|
+
ctx := r.Context()
|
|
127
|
+
|
|
128
|
+
// Extract and validate ID
|
|
129
|
+
idStr := chi.URLParam(r, "id")
|
|
130
|
+
id, err := strconv.ParseInt(idStr, 10, 64)
|
|
131
|
+
if err != nil {
|
|
132
|
+
http.Error(w, "Invalid user ID", http.StatusBadRequest)
|
|
133
|
+
return
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Get user
|
|
137
|
+
user, err := s.userService.GetUser(ctx, id)
|
|
138
|
+
if err != nil {
|
|
139
|
+
http.Error(w, "User not found", http.StatusNotFound)
|
|
140
|
+
return
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Return user
|
|
144
|
+
w.Header().Set("Content-Type", "application/json")
|
|
145
|
+
json.NewEncoder(w).Encode(user)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// CreateUserRequest represents the request body for creating a user
|
|
149
|
+
type CreateUserRequest struct {
|
|
150
|
+
Name string `json:"name"`
|
|
151
|
+
Email string `json:"email"`
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// handleCreateUser handles POST /api/v1/users
|
|
155
|
+
func (s *Server) handleCreateUser(w http.ResponseWriter, r *http.Request) {
|
|
156
|
+
ctx := r.Context()
|
|
157
|
+
|
|
158
|
+
// Parse request body
|
|
159
|
+
var req CreateUserRequest
|
|
160
|
+
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
|
161
|
+
http.Error(w, "Invalid request body", http.StatusBadRequest)
|
|
162
|
+
return
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Validate input
|
|
166
|
+
if req.Name == "" || req.Email == "" {
|
|
167
|
+
http.Error(w, "Name and email are required", http.StatusBadRequest)
|
|
168
|
+
return
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Create user
|
|
172
|
+
user, err := s.userService.CreateUser(ctx, req.Name, req.Email)
|
|
173
|
+
if err != nil {
|
|
174
|
+
http.Error(w, "Failed to create user", http.StatusInternalServerError)
|
|
175
|
+
return
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Return created user
|
|
179
|
+
w.Header().Set("Content-Type", "application/json")
|
|
180
|
+
w.WriteHeader(http.StatusCreated)
|
|
181
|
+
json.NewEncoder(w).Encode(user)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Shutdown gracefully shuts down the server
|
|
185
|
+
func (s *Server) Shutdown(ctx context.Context) error {
|
|
186
|
+
s.logger.Info("Starting graceful shutdown")
|
|
187
|
+
return s.http.Shutdown(ctx)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
func main() {
|
|
191
|
+
// Create logger
|
|
192
|
+
logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
|
|
193
|
+
|
|
194
|
+
// Create server
|
|
195
|
+
srv := NewServer(":8080", logger)
|
|
196
|
+
|
|
197
|
+
// Start server in goroutine
|
|
198
|
+
go func() {
|
|
199
|
+
logger.Info("Server starting", "addr", srv.http.Addr)
|
|
200
|
+
if err := srv.http.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
|
201
|
+
logger.Error("Server failed", "error", err)
|
|
202
|
+
os.Exit(1)
|
|
203
|
+
}
|
|
204
|
+
}()
|
|
205
|
+
|
|
206
|
+
// Wait for interrupt signal
|
|
207
|
+
quit := make(chan os.Signal, 1)
|
|
208
|
+
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
|
209
|
+
<-quit
|
|
210
|
+
|
|
211
|
+
logger.Info("Shutdown signal received")
|
|
212
|
+
|
|
213
|
+
// Graceful shutdown with timeout
|
|
214
|
+
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
215
|
+
defer cancel()
|
|
216
|
+
|
|
217
|
+
if err := srv.Shutdown(ctx); err != nil {
|
|
218
|
+
logger.Error("Shutdown error", "error", err)
|
|
219
|
+
os.Exit(1)
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
logger.Info("Server stopped")
|
|
223
|
+
}
|
|
224
|
+
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "go-coding-standards",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Professional Go coding standards for Augment Code AI covering web services, microservices, CLI tools, cloud-native applications, distributed systems, DevOps tooling, and API development",
|
|
5
|
+
"displayName": "Go Coding Standards",
|
|
6
|
+
"type": "coding-standards",
|
|
7
|
+
"author": "MyTech Today",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/mytech-today-now/augment-extensions"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"go",
|
|
15
|
+
"golang",
|
|
16
|
+
"coding-standards",
|
|
17
|
+
"best-practices",
|
|
18
|
+
"style-guide",
|
|
19
|
+
"web-services",
|
|
20
|
+
"microservices",
|
|
21
|
+
"cli",
|
|
22
|
+
"cloud-native",
|
|
23
|
+
"distributed-systems",
|
|
24
|
+
"devops",
|
|
25
|
+
"api-development"
|
|
26
|
+
],
|
|
27
|
+
"categories": [
|
|
28
|
+
{
|
|
29
|
+
"id": "web",
|
|
30
|
+
"name": "Web Services",
|
|
31
|
+
"description": "HTTP server development, middleware patterns, request/response handling, routing (net/http, gorilla/mux, chi), graceful shutdown, TLS configuration"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "microservices",
|
|
35
|
+
"name": "Microservices",
|
|
36
|
+
"description": "Service discovery, health checks, circuit breakers, distributed tracing (OpenTelemetry), metrics (Prometheus), gRPC communication, service mesh integration"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": "cli",
|
|
40
|
+
"name": "CLI Tools",
|
|
41
|
+
"description": "Command-line parsing (cobra, urfave/cli), flag handling, configuration management (viper), output formatting, exit codes, cross-platform compatibility"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"id": "cloud",
|
|
45
|
+
"name": "Cloud-Native Applications",
|
|
46
|
+
"description": "Containerization (Docker), Kubernetes operators, cloud provider SDKs (AWS, GCP, Azure), 12-factor app principles, environment-based configuration"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"id": "distributed",
|
|
50
|
+
"name": "Distributed Systems",
|
|
51
|
+
"description": "Consensus algorithms, event sourcing, CQRS patterns, message queues (NATS, Kafka, RabbitMQ), distributed locks, eventual consistency"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"id": "devops",
|
|
55
|
+
"name": "DevOps Tooling",
|
|
56
|
+
"description": "Infrastructure automation, CI/CD pipelines, configuration management, monitoring agents, log aggregation, GitOps workflows"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"id": "api",
|
|
60
|
+
"name": "API Development",
|
|
61
|
+
"description": "RESTful API design, GraphQL servers, API versioning, authentication/authorization (JWT, OAuth2), rate limiting, OpenAPI/Swagger documentation"
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
"tags": [
|
|
65
|
+
"go1.18+",
|
|
66
|
+
"effective-go",
|
|
67
|
+
"uber-style-guide",
|
|
68
|
+
"google-style-guide",
|
|
69
|
+
"golangci-lint",
|
|
70
|
+
"staticcheck",
|
|
71
|
+
"concurrency",
|
|
72
|
+
"error-handling",
|
|
73
|
+
"testing",
|
|
74
|
+
"performance"
|
|
75
|
+
],
|
|
76
|
+
"dependencies": {
|
|
77
|
+
"augment-extensions": "^1.4.0"
|
|
78
|
+
},
|
|
79
|
+
"peerDependencies": {
|
|
80
|
+
"go": ">=1.18.0"
|
|
81
|
+
},
|
|
82
|
+
"engines": {
|
|
83
|
+
"node": ">=14.0.0",
|
|
84
|
+
"augment": ">=1.0.0"
|
|
85
|
+
},
|
|
86
|
+
"compatibility": {
|
|
87
|
+
"go": {
|
|
88
|
+
"minimum": "1.18.0",
|
|
89
|
+
"recommended": "1.21.0",
|
|
90
|
+
"features": {
|
|
91
|
+
"generics": "1.18.0",
|
|
92
|
+
"fuzzing": "1.18.0",
|
|
93
|
+
"workspace": "1.18.0"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"configSchema": "./config/schema.json",
|
|
98
|
+
"configuration": {
|
|
99
|
+
"defaults": {
|
|
100
|
+
"categories": ["web"],
|
|
101
|
+
"rules": {
|
|
102
|
+
"enabled": true,
|
|
103
|
+
"severity": "error"
|
|
104
|
+
},
|
|
105
|
+
"staticAnalysis": {
|
|
106
|
+
"golangci-lint": true,
|
|
107
|
+
"staticcheck": true,
|
|
108
|
+
"govet": true,
|
|
109
|
+
"gosec": true
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"options": {
|
|
113
|
+
"categories": "Array of category IDs to enable (web, microservices, cli, cloud, distributed, devops, api)",
|
|
114
|
+
"rules.enabled": "Enable/disable all rules (boolean)",
|
|
115
|
+
"rules.severity": "Default severity level (error, warning, info)",
|
|
116
|
+
"staticAnalysis": "Enable/disable static analysis tools"
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"metrics": {
|
|
120
|
+
"characterCount": 270991,
|
|
121
|
+
"characterCountByCategory": {
|
|
122
|
+
"core": 12500,
|
|
123
|
+
"rules": 80000,
|
|
124
|
+
"templates": 50000,
|
|
125
|
+
"examples": 60000,
|
|
126
|
+
"documentation": 30000,
|
|
127
|
+
"tests": 40000
|
|
128
|
+
},
|
|
129
|
+
"files": {
|
|
130
|
+
"total": 50,
|
|
131
|
+
"rules": 14,
|
|
132
|
+
"templates": 7,
|
|
133
|
+
"examples": 10,
|
|
134
|
+
"tests": 10,
|
|
135
|
+
"documentation": 9
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
package/augment-extensions/coding-standards/go/rules/categories/api-development/api-versioning.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# API Versioning Rules
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Best practices for versioning REST APIs in Go including URL versioning, header versioning, and backward compatibility.
|
|
6
|
+
|
|
7
|
+
## Rules
|
|
8
|
+
|
|
9
|
+
### 1. Use URL Path Versioning
|
|
10
|
+
|
|
11
|
+
**Rule**: Include API version in the URL path for clarity.
|
|
12
|
+
|
|
13
|
+
**Good Example**:
|
|
14
|
+
```go
|
|
15
|
+
func SetupVersionedRoutes(r *mux.Router) {
|
|
16
|
+
// Version 1
|
|
17
|
+
v1 := r.PathPrefix("/api/v1").Subrouter()
|
|
18
|
+
v1.HandleFunc("/users", v1.ListUsers).Methods("GET")
|
|
19
|
+
v1.HandleFunc("/users/{id}", v1.GetUser).Methods("GET")
|
|
20
|
+
|
|
21
|
+
// Version 2
|
|
22
|
+
v2 := r.PathPrefix("/api/v2").Subrouter()
|
|
23
|
+
v2.HandleFunc("/users", v2.ListUsers).Methods("GET")
|
|
24
|
+
v2.HandleFunc("/users/{id}", v2.GetUser).Methods("GET")
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 2. Maintain Backward Compatibility
|
|
29
|
+
|
|
30
|
+
**Rule**: Keep old API versions functional while introducing new versions.
|
|
31
|
+
|
|
32
|
+
**Good Example**:
|
|
33
|
+
```go
|
|
34
|
+
// V1 User structure
|
|
35
|
+
type UserV1 struct {
|
|
36
|
+
ID string `json:"id"`
|
|
37
|
+
Name string `json:"name"`
|
|
38
|
+
Email string `json:"email"`
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// V2 User structure with additional fields
|
|
42
|
+
type UserV2 struct {
|
|
43
|
+
ID string `json:"id"`
|
|
44
|
+
FirstName string `json:"first_name"`
|
|
45
|
+
LastName string `json:"last_name"`
|
|
46
|
+
Email string `json:"email"`
|
|
47
|
+
CreatedAt time.Time `json:"created_at"`
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Convert internal model to V1
|
|
51
|
+
func toUserV1(user *User) *UserV1 {
|
|
52
|
+
return &UserV1{
|
|
53
|
+
ID: user.ID,
|
|
54
|
+
Name: user.FirstName + " " + user.LastName,
|
|
55
|
+
Email: user.Email,
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Convert internal model to V2
|
|
60
|
+
func toUserV2(user *User) *UserV2 {
|
|
61
|
+
return &UserV2{
|
|
62
|
+
ID: user.ID,
|
|
63
|
+
FirstName: user.FirstName,
|
|
64
|
+
LastName: user.LastName,
|
|
65
|
+
Email: user.Email,
|
|
66
|
+
CreatedAt: user.CreatedAt,
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 3. Document Version Deprecation
|
|
72
|
+
|
|
73
|
+
**Rule**: Clearly communicate version deprecation timelines.
|
|
74
|
+
|
|
75
|
+
**Good Example**:
|
|
76
|
+
```go
|
|
77
|
+
func DeprecationMiddleware(version string, sunsetDate time.Time) func(http.Handler) http.Handler {
|
|
78
|
+
return func(next http.Handler) http.Handler {
|
|
79
|
+
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
80
|
+
w.Header().Set("Deprecation", "true")
|
|
81
|
+
w.Header().Set("Sunset", sunsetDate.Format(time.RFC1123))
|
|
82
|
+
w.Header().Set("Link", fmt.Sprintf("</api/%s>; rel=\"successor-version\"", version))
|
|
83
|
+
|
|
84
|
+
next.ServeHTTP(w, r)
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Apply to deprecated version
|
|
90
|
+
v1Router.Use(DeprecationMiddleware("v2", time.Date(2026, 12, 31, 0, 0, 0, 0, time.UTC)))
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 4. Support Content Negotiation
|
|
94
|
+
|
|
95
|
+
**Rule**: Allow clients to specify version via Accept header as alternative.
|
|
96
|
+
|
|
97
|
+
**Good Example**:
|
|
98
|
+
```go
|
|
99
|
+
func VersionMiddleware(next http.Handler) http.Handler {
|
|
100
|
+
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
101
|
+
version := "v1" // default
|
|
102
|
+
|
|
103
|
+
// Check Accept header
|
|
104
|
+
accept := r.Header.Get("Accept")
|
|
105
|
+
if strings.Contains(accept, "application/vnd.api.v2+json") {
|
|
106
|
+
version = "v2"
|
|
107
|
+
} else if strings.Contains(accept, "application/vnd.api.v1+json") {
|
|
108
|
+
version = "v1"
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Store version in context
|
|
112
|
+
ctx := context.WithValue(r.Context(), "api_version", version)
|
|
113
|
+
next.ServeHTTP(w, r.WithContext(ctx))
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 5. Version Breaking Changes Only
|
|
119
|
+
|
|
120
|
+
**Rule**: Only increment version for breaking changes, not additions.
|
|
121
|
+
|
|
122
|
+
**Good Example**:
|
|
123
|
+
```go
|
|
124
|
+
// V1 - Original
|
|
125
|
+
type CreateUserRequestV1 struct {
|
|
126
|
+
Name string `json:"name"`
|
|
127
|
+
Email string `json:"email"`
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// V1.1 - Added optional field (backward compatible, no version bump)
|
|
131
|
+
type CreateUserRequestV1 struct {
|
|
132
|
+
Name string `json:"name"`
|
|
133
|
+
Email string `json:"email"`
|
|
134
|
+
Phone *string `json:"phone,omitempty"` // Optional, backward compatible
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// V2 - Breaking change (required field changed)
|
|
138
|
+
type CreateUserRequestV2 struct {
|
|
139
|
+
FirstName string `json:"first_name"` // Breaking: split name field
|
|
140
|
+
LastName string `json:"last_name"` // Breaking: split name field
|
|
141
|
+
Email string `json:"email"`
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## References
|
|
146
|
+
|
|
147
|
+
- [API Versioning Best Practices](https://www.freecodecamp.org/news/how-to-version-a-rest-api/)
|
|
148
|
+
- [Semantic Versioning](https://semver.org/)
|
|
149
|
+
|