@mytechtoday/augment-extensions 1.3.1 → 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.
Files changed (172) hide show
  1. package/README.md +105 -6
  2. package/augment-extensions/coding-standards/c/CHANGELOG.md +55 -0
  3. package/augment-extensions/coding-standards/c/LICENSE +22 -0
  4. package/augment-extensions/coding-standards/c/README.md +167 -0
  5. package/augment-extensions/coding-standards/c/config/defaults.json +26 -0
  6. package/augment-extensions/coding-standards/c/config/examples/embedded.yaml +25 -0
  7. package/augment-extensions/coding-standards/c/config/examples/systems.json +31 -0
  8. package/augment-extensions/coding-standards/c/config/schema.json +244 -0
  9. package/augment-extensions/coding-standards/c/docs/API.md +613 -0
  10. package/augment-extensions/coding-standards/c/docs/CONFIGURATION.md +259 -0
  11. package/augment-extensions/coding-standards/c/docs/USER_GUIDE.md +567 -0
  12. package/augment-extensions/coding-standards/c/examples/drivers/Makefile +33 -0
  13. package/augment-extensions/coding-standards/c/examples/drivers/README.md +192 -0
  14. package/augment-extensions/coding-standards/c/examples/drivers/dma-example.c +224 -0
  15. package/augment-extensions/coding-standards/c/examples/drivers/example.dts +64 -0
  16. package/augment-extensions/coding-standards/c/examples/drivers/platform-driver.c +174 -0
  17. package/augment-extensions/coding-standards/c/examples/embedded/README.md +167 -0
  18. package/augment-extensions/coding-standards/c/examples/embedded/gpio-control.c +172 -0
  19. package/augment-extensions/coding-standards/c/examples/embedded/timer-isr.c +198 -0
  20. package/augment-extensions/coding-standards/c/examples/embedded/uart-communication.c +212 -0
  21. package/augment-extensions/coding-standards/c/examples/kernel/Makefile +82 -0
  22. package/augment-extensions/coding-standards/c/examples/kernel/README.md +168 -0
  23. package/augment-extensions/coding-standards/c/examples/kernel/char-device.c +198 -0
  24. package/augment-extensions/coding-standards/c/examples/kernel/proc-file.c +131 -0
  25. package/augment-extensions/coding-standards/c/examples/kernel/simple-module.c +111 -0
  26. package/augment-extensions/coding-standards/c/examples/legacy/Makefile +62 -0
  27. package/augment-extensions/coding-standards/c/examples/legacy/README.md +255 -0
  28. package/augment-extensions/coding-standards/c/examples/legacy/c89-to-c11-migration.c +268 -0
  29. package/augment-extensions/coding-standards/c/examples/legacy/compatibility-layer.c +239 -0
  30. package/augment-extensions/coding-standards/c/examples/networking/Makefile +35 -0
  31. package/augment-extensions/coding-standards/c/examples/networking/README.md +207 -0
  32. package/augment-extensions/coding-standards/c/examples/networking/protocol-parser.c +270 -0
  33. package/augment-extensions/coding-standards/c/examples/networking/tcp-server.c +197 -0
  34. package/augment-extensions/coding-standards/c/examples/networking/udp-multicast.c +220 -0
  35. package/augment-extensions/coding-standards/c/examples/realtime/Makefile +53 -0
  36. package/augment-extensions/coding-standards/c/examples/realtime/README.md +199 -0
  37. package/augment-extensions/coding-standards/c/examples/realtime/deadline-monitoring.c +260 -0
  38. package/augment-extensions/coding-standards/c/examples/realtime/priority-scheduling.c +258 -0
  39. package/augment-extensions/coding-standards/c/examples/systems/Makefile +34 -0
  40. package/augment-extensions/coding-standards/c/examples/systems/README.md +123 -0
  41. package/augment-extensions/coding-standards/c/examples/systems/ipc-pipes.c +181 -0
  42. package/augment-extensions/coding-standards/c/examples/systems/process-management.c +153 -0
  43. package/augment-extensions/coding-standards/c/examples/systems/signal-handling.c +162 -0
  44. package/augment-extensions/coding-standards/c/module.json +149 -0
  45. package/augment-extensions/coding-standards/c/rules/categories/drivers.md +635 -0
  46. package/augment-extensions/coding-standards/c/rules/categories/embedded.md +510 -0
  47. package/augment-extensions/coding-standards/c/rules/categories/kernel.md +653 -0
  48. package/augment-extensions/coding-standards/c/rules/categories/legacy.md +526 -0
  49. package/augment-extensions/coding-standards/c/rules/categories/networking.md +735 -0
  50. package/augment-extensions/coding-standards/c/rules/categories/realtime.md +631 -0
  51. package/augment-extensions/coding-standards/c/rules/categories/systems.md +586 -0
  52. package/augment-extensions/coding-standards/c/rules/universal/const-correctness.md +275 -0
  53. package/augment-extensions/coding-standards/c/rules/universal/documentation.md +251 -0
  54. package/augment-extensions/coding-standards/c/rules/universal/error-handling.md +250 -0
  55. package/augment-extensions/coding-standards/c/rules/universal/header-guards.md +254 -0
  56. package/augment-extensions/coding-standards/c/rules/universal/memory-safety.md +233 -0
  57. package/augment-extensions/coding-standards/c/rules/universal/naming.md +146 -0
  58. package/augment-extensions/coding-standards/c/src/conflict-detector.ts +461 -0
  59. package/augment-extensions/coding-standards/c/src/prompt-generator.ts +307 -0
  60. package/augment-extensions/coding-standards/c/src/rule-evaluator.ts +307 -0
  61. package/augment-extensions/coding-standards/c/src/rule-override.ts +427 -0
  62. package/augment-extensions/coding-standards/c/src/template-engine.ts +217 -0
  63. package/augment-extensions/coding-standards/c/templates/prompts/drivers.txt +191 -0
  64. package/augment-extensions/coding-standards/c/templates/prompts/embedded.txt +164 -0
  65. package/augment-extensions/coding-standards/c/templates/prompts/kernel.txt +175 -0
  66. package/augment-extensions/coding-standards/c/templates/prompts/legacy.txt +280 -0
  67. package/augment-extensions/coding-standards/c/templates/prompts/networking.txt +259 -0
  68. package/augment-extensions/coding-standards/c/templates/prompts/realtime.txt +219 -0
  69. package/augment-extensions/coding-standards/c/templates/prompts/systems.txt +147 -0
  70. package/augment-extensions/coding-standards/c/tests/integration/category-specific.test.ts +356 -0
  71. package/augment-extensions/coding-standards/c/tests/integration/end-to-end-workflow.test.ts +377 -0
  72. package/augment-extensions/coding-standards/c/tests/performance/benchmarks.test.ts +407 -0
  73. package/augment-extensions/coding-standards/c/tests/unit/config-manager.test.ts +345 -0
  74. package/augment-extensions/coding-standards/c/tests/unit/conflict-detector.test.ts +294 -0
  75. package/augment-extensions/coding-standards/c/tests/unit/prompt-generator.test.ts +174 -0
  76. package/augment-extensions/coding-standards/c/tests/unit/registry.test.ts +313 -0
  77. package/augment-extensions/coding-standards/c/tests/unit/rule-evaluator.test.ts +318 -0
  78. package/augment-extensions/coding-standards/c/tests/unit/rule-override.test.ts +326 -0
  79. package/augment-extensions/coding-standards/c/tests/unit/template-engine.test.ts +314 -0
  80. package/augment-extensions/coding-standards/go/CHARACTER-COUNT-REPORT.md +135 -0
  81. package/augment-extensions/coding-standards/go/PHASE1-COMPLETION.md +146 -0
  82. package/augment-extensions/coding-standards/go/PHASE4-COMPLETION.md +184 -0
  83. package/augment-extensions/coding-standards/go/README.md +200 -0
  84. package/augment-extensions/coding-standards/go/VALIDATION-CHECKLIST.md +154 -0
  85. package/augment-extensions/coding-standards/go/config/examples/example-cli.json +15 -0
  86. package/augment-extensions/coding-standards/go/config/examples/example-microservices.json +21 -0
  87. package/augment-extensions/coding-standards/go/config/examples/example-multi-category.yaml +24 -0
  88. package/augment-extensions/coding-standards/go/config/examples/example-web.json +15 -0
  89. package/augment-extensions/coding-standards/go/config/schema.json +110 -0
  90. package/augment-extensions/coding-standards/go/docs/CATEGORIES.md +221 -0
  91. package/augment-extensions/coding-standards/go/docs/CONFIGURATION.md +198 -0
  92. package/augment-extensions/coding-standards/go/docs/TROUBLESHOOTING.md +285 -0
  93. package/augment-extensions/coding-standards/go/examples/cli/cobra-app.go +287 -0
  94. package/augment-extensions/coding-standards/go/examples/cloud-native-app.go +217 -0
  95. package/augment-extensions/coding-standards/go/examples/devops-tool.go +250 -0
  96. package/augment-extensions/coding-standards/go/examples/distributed-system.go +247 -0
  97. package/augment-extensions/coding-standards/go/examples/microservices/grpc-service.go +253 -0
  98. package/augment-extensions/coding-standards/go/examples/rest-api.go +270 -0
  99. package/augment-extensions/coding-standards/go/examples/web/http-server.go +224 -0
  100. package/augment-extensions/coding-standards/go/module.json +139 -0
  101. package/augment-extensions/coding-standards/go/rules/categories/api-development/api-versioning.md +149 -0
  102. package/augment-extensions/coding-standards/go/rules/categories/api-development/rate-limiting.md +209 -0
  103. package/augment-extensions/coding-standards/go/rules/categories/api-development/rest-api-design.md +183 -0
  104. package/augment-extensions/coding-standards/go/rules/categories/cloud-native/cloud-config.md +193 -0
  105. package/augment-extensions/coding-standards/go/rules/categories/cloud-native/health-checks.md +231 -0
  106. package/augment-extensions/coding-standards/go/rules/categories/cloud-native/kubernetes.md +180 -0
  107. package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/automation.md +179 -0
  108. package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/ci-cd-integration.md +147 -0
  109. package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/infrastructure-as-code.md +231 -0
  110. package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/caching.md +150 -0
  111. package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/consensus.md +187 -0
  112. package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/event-sourcing.md +246 -0
  113. package/augment-extensions/coding-standards/go/rules/cli/command-parsing.md +264 -0
  114. package/augment-extensions/coding-standards/go/rules/cli/configuration.md +268 -0
  115. package/augment-extensions/coding-standards/go/rules/cli/cross-platform.md +324 -0
  116. package/augment-extensions/coding-standards/go/rules/microservices/distributed-tracing.md +253 -0
  117. package/augment-extensions/coding-standards/go/rules/microservices/grpc.md +257 -0
  118. package/augment-extensions/coding-standards/go/rules/microservices/metrics.md +278 -0
  119. package/augment-extensions/coding-standards/go/rules/microservices/service-discovery.md +249 -0
  120. package/augment-extensions/coding-standards/go/rules/universal/code-organization.md +221 -0
  121. package/augment-extensions/coding-standards/go/rules/universal/documentation.md +269 -0
  122. package/augment-extensions/coding-standards/go/rules/universal/performance.md +323 -0
  123. package/augment-extensions/coding-standards/go/rules/universal/testing.md +162 -0
  124. package/augment-extensions/coding-standards/go/rules/web/graceful-shutdown.md +249 -0
  125. package/augment-extensions/coding-standards/go/rules/web/http-handlers.md +164 -0
  126. package/augment-extensions/coding-standards/go/rules/web/middleware.md +234 -0
  127. package/augment-extensions/coding-standards/go/rules/web/routing.md +251 -0
  128. package/augment-extensions/coding-standards/go/templates/prompts/api.md +160 -0
  129. package/augment-extensions/coding-standards/go/templates/prompts/cli.md +225 -0
  130. package/augment-extensions/coding-standards/go/templates/prompts/cloud-native.md +121 -0
  131. package/augment-extensions/coding-standards/go/templates/prompts/devops.md +146 -0
  132. package/augment-extensions/coding-standards/go/templates/prompts/distributed.md +133 -0
  133. package/augment-extensions/coding-standards/go/templates/prompts/microservices.md +225 -0
  134. package/augment-extensions/coding-standards/go/templates/prompts/web.md +181 -0
  135. package/augment-extensions/coding-standards/go/tests/integration/module-integration.test.ts +164 -0
  136. package/augment-extensions/coding-standards/go/tests/unit/category-selection.test.ts +147 -0
  137. package/augment-extensions/coding-standards/go/tests/unit/module-structure.test.ts +154 -0
  138. package/augment-extensions/coding-standards/go/tests/validate-character-count.ps1 +13 -0
  139. package/augment-extensions/coding-standards/go/tests/validate-examples.ps1 +148 -0
  140. package/augment-extensions/coding-standards/go/tests/validate-examples.sh +135 -0
  141. package/cli/dist/analysis/ast-parser.d.ts +47 -0
  142. package/cli/dist/analysis/ast-parser.d.ts.map +1 -0
  143. package/cli/dist/analysis/ast-parser.js +161 -0
  144. package/cli/dist/analysis/ast-parser.js.map +1 -0
  145. package/cli/dist/analysis/complexity-analyzer.d.ts +27 -0
  146. package/cli/dist/analysis/complexity-analyzer.d.ts.map +1 -0
  147. package/cli/dist/analysis/complexity-analyzer.js +189 -0
  148. package/cli/dist/analysis/complexity-analyzer.js.map +1 -0
  149. package/cli/dist/analysis/dependency-analyzer.d.ts +23 -0
  150. package/cli/dist/analysis/dependency-analyzer.d.ts.map +1 -0
  151. package/cli/dist/analysis/dependency-analyzer.js +237 -0
  152. package/cli/dist/analysis/dependency-analyzer.js.map +1 -0
  153. package/cli/dist/analysis/index.d.ts +9 -0
  154. package/cli/dist/analysis/index.d.ts.map +1 -0
  155. package/cli/dist/analysis/index.js +25 -0
  156. package/cli/dist/analysis/index.js.map +1 -0
  157. package/cli/dist/analysis/security-scanner.d.ts +11 -0
  158. package/cli/dist/analysis/security-scanner.d.ts.map +1 -0
  159. package/cli/dist/analysis/security-scanner.js +294 -0
  160. package/cli/dist/analysis/security-scanner.js.map +1 -0
  161. package/cli/dist/analysis/types.d.ts +151 -0
  162. package/cli/dist/analysis/types.d.ts.map +1 -0
  163. package/cli/dist/analysis/types.js +6 -0
  164. package/cli/dist/analysis/types.js.map +1 -0
  165. package/cli/dist/cli.js +24 -0
  166. package/cli/dist/cli.js.map +1 -1
  167. package/cli/dist/commands/code-analysis.d.ts +11 -0
  168. package/cli/dist/commands/code-analysis.d.ts.map +1 -0
  169. package/cli/dist/commands/code-analysis.js +412 -0
  170. package/cli/dist/commands/code-analysis.js.map +1 -0
  171. package/modules.md +99 -3
  172. package/package.json +21 -2
@@ -0,0 +1,221 @@
1
+ # Go Code Organization Rules
2
+
3
+ ## Overview
4
+
5
+ This document defines universal code organization best practices for Go projects. These rules apply to all Go code regardless of project category.
6
+
7
+ ## Core Principles
8
+
9
+ 1. **Flat Package Structure**: Avoid deep nesting; prefer flat, focused packages
10
+ 2. **Internal Packages**: Use `internal/` for private implementation details
11
+ 3. **Import Grouping**: Group imports logically (stdlib, external, internal)
12
+ 4. **File Organization**: Organize code by responsibility, not by type
13
+ 5. **Dependency Management**: Use `go.mod` for explicit dependency versioning
14
+
15
+ ## Rules
16
+
17
+ ### GOL.2.5.1: Package Structure (Flat, Avoid Deep Nesting)
18
+
19
+ **Rule**: Keep package structure flat and focused. Avoid deep directory hierarchies.
20
+
21
+ **Rationale**: Flat structures are easier to navigate, understand, and maintain. Deep nesting often indicates poor separation of concerns.
22
+
23
+ **Good Example**:
24
+ ```
25
+ myproject/
26
+ ├── cmd/
27
+ │ └── myapp/
28
+ │ └── main.go
29
+ ├── internal/
30
+ │ ├── auth/
31
+ │ ├── database/
32
+ │ └── handler/
33
+ ├── pkg/
34
+ │ └── api/
35
+ ├── go.mod
36
+ └── go.sum
37
+ ```
38
+
39
+ **Bad Example**:
40
+ ```
41
+ myproject/
42
+ ├── src/
43
+ │ └── main/
44
+ │ └── java/
45
+ │ └── com/
46
+ │ └── company/
47
+ │ └── project/ # Too deep!
48
+ ```
49
+
50
+ **Guidelines**:
51
+ - Keep packages at 2-3 levels deep maximum
52
+ - Each package should have a single, clear responsibility
53
+ - Use `cmd/` for application entry points
54
+ - Use `internal/` for private packages
55
+ - Use `pkg/` for public, reusable packages (optional)
56
+
57
+ ### GOL.2.5.2: Internal Package Usage
58
+
59
+ **Rule**: Use `internal/` directory to prevent external imports of private packages.
60
+
61
+ **Rationale**: The Go compiler enforces that `internal/` packages can only be imported by code in the parent tree, providing true encapsulation.
62
+
63
+ **Example**:
64
+ ```
65
+ myproject/
66
+ ├── internal/
67
+ │ ├── auth/ # Only importable by myproject
68
+ │ │ └── jwt.go
69
+ │ └── database/ # Only importable by myproject
70
+ │ └── postgres.go
71
+ ├── pkg/
72
+ │ └── api/ # Publicly importable
73
+ │ └── client.go
74
+ └── cmd/
75
+ └── server/
76
+ └── main.go
77
+ ```
78
+
79
+ **Usage**:
80
+ ```go
81
+ // In cmd/server/main.go
82
+ import (
83
+ "myproject/internal/auth" // OK: same parent tree
84
+ "myproject/internal/database" // OK: same parent tree
85
+ "myproject/pkg/api" // OK: public package
86
+ )
87
+
88
+ // In external project
89
+ import (
90
+ "myproject/internal/auth" // ERROR: cannot import internal package
91
+ "myproject/pkg/api" // OK: public package
92
+ )
93
+ ```
94
+
95
+ ### GOL.2.5.3: Import Grouping (stdlib, external, internal)
96
+
97
+ **Rule**: Group imports into three sections: standard library, external packages, and internal packages.
98
+
99
+ **Rationale**: Consistent import grouping improves readability and makes dependencies clear.
100
+
101
+ **Example**:
102
+ ```go
103
+ package main
104
+
105
+ import (
106
+ // Standard library
107
+ "context"
108
+ "fmt"
109
+ "net/http"
110
+ "time"
111
+
112
+ // External packages
113
+ "github.com/gorilla/mux"
114
+ "github.com/sirupsen/logrus"
115
+ "go.uber.org/zap"
116
+
117
+ // Internal packages
118
+ "myproject/internal/auth"
119
+ "myproject/internal/database"
120
+ "myproject/pkg/api"
121
+ )
122
+ ```
123
+
124
+ **Tool**: Use `goimports` to automatically format and group imports:
125
+ ```bash
126
+ goimports -w .
127
+ ```
128
+
129
+ ### GOL.2.5.4: File Organization Patterns
130
+
131
+ **Rule**: Organize files by responsibility, not by type. Keep related code together.
132
+
133
+ **Rationale**: Grouping by responsibility makes it easier to find and modify related code.
134
+
135
+ **Good Example** (by responsibility):
136
+ ```
137
+ user/
138
+ ├── user.go # User type and core logic
139
+ ├── repository.go # Database operations
140
+ ├── service.go # Business logic
141
+ ├── handler.go # HTTP handlers
142
+ └── user_test.go # Tests
143
+ ```
144
+
145
+ **Bad Example** (by type):
146
+ ```
147
+ models/
148
+ ├── user.go
149
+ ├── product.go
150
+ repositories/
151
+ ├── user_repository.go
152
+ ├── product_repository.go
153
+ services/
154
+ ├── user_service.go
155
+ ├── product_service.go
156
+ ```
157
+
158
+ **Guidelines**:
159
+ - Keep related types and functions in the same package
160
+ - Use `_test.go` suffix for test files
161
+ - Use `doc.go` for package-level documentation
162
+ - Limit file size to ~500 lines; split if larger
163
+
164
+ ### GOL.2.5.5: Go.mod Dependency Management
165
+
166
+ **Rule**: Use `go.mod` for explicit dependency versioning and management.
167
+
168
+ **Rationale**: `go.mod` provides reproducible builds, semantic versioning, and dependency isolation.
169
+
170
+ **Example go.mod**:
171
+ ```go
172
+ module github.com/mycompany/myproject
173
+
174
+ go 1.21
175
+
176
+ require (
177
+ github.com/gorilla/mux v1.8.0
178
+ github.com/sirupsen/logrus v1.9.3
179
+ go.uber.org/zap v1.26.0
180
+ )
181
+
182
+ require (
183
+ // Indirect dependencies
184
+ go.uber.org/multierr v1.11.0 // indirect
185
+ golang.org/x/sys v0.15.0 // indirect
186
+ )
187
+ ```
188
+
189
+ **Best Practices**:
190
+ - Run `go mod tidy` regularly to clean up unused dependencies
191
+ - Use `go mod vendor` for vendoring if needed
192
+ - Pin major versions explicitly
193
+ - Use `replace` directive for local development only
194
+ - Document why `replace` directives exist
195
+
196
+ **Commands**:
197
+ ```bash
198
+ go mod init github.com/mycompany/myproject # Initialize module
199
+ go mod tidy # Clean up dependencies
200
+ go mod download # Download dependencies
201
+ go mod verify # Verify dependencies
202
+ go mod vendor # Vendor dependencies
203
+ ```
204
+
205
+ ## Package Naming Conventions
206
+
207
+ **Rule**: Use short, lowercase, single-word package names.
208
+
209
+ **Examples**:
210
+ - Good: `http`, `auth`, `user`, `database`
211
+ - Bad: `httpServer`, `AuthenticationService`, `user_management`
212
+
213
+ **Rationale**: Package names are used in every import and type reference. Short names reduce verbosity.
214
+
215
+ ## References
216
+
217
+ - [Go Project Layout](https://github.com/golang-standards/project-layout)
218
+ - [Effective Go - Package Names](https://go.dev/doc/effective_go#package-names)
219
+ - [Go Modules Reference](https://go.dev/ref/mod)
220
+ - [Internal Packages](https://go.dev/doc/go1.4#internalpackages)
221
+
@@ -0,0 +1,269 @@
1
+ # Go Documentation Rules
2
+
3
+ ## Overview
4
+
5
+ This document defines universal documentation best practices for Go projects. These rules apply to all Go code regardless of project category.
6
+
7
+ ## Core Principles
8
+
9
+ 1. **Package Comments**: Every package must have a package comment
10
+ 2. **Function Comments**: Document all exported functions and methods
11
+ 3. **Example Tests**: Use Example tests for executable documentation
12
+ 4. **Godoc Compatibility**: Write comments that render well in godoc
13
+ 5. **README Requirements**: Maintain comprehensive README.md files
14
+
15
+ ## Rules
16
+
17
+ ### GOL.2.6.1: Package Comment Requirements
18
+
19
+ **Rule**: Every package must have a package comment that describes its purpose.
20
+
21
+ **Rationale**: Package comments appear in godoc and help users understand the package's role.
22
+
23
+ **Format**:
24
+ - Start with "Package [name]" for single-file packages
25
+ - Use `doc.go` for multi-file packages
26
+ - Write complete sentences
27
+ - Explain what the package does, not how it works
28
+
29
+ **Example (doc.go)**:
30
+ ```go
31
+ // Package auth provides authentication and authorization functionality
32
+ // for the application. It supports JWT tokens, OAuth2, and API keys.
33
+ //
34
+ // Basic usage:
35
+ //
36
+ // authenticator := auth.NewAuthenticator(config)
37
+ // token, err := authenticator.GenerateToken(user)
38
+ // if err != nil {
39
+ // log.Fatal(err)
40
+ // }
41
+ //
42
+ // The package also provides middleware for HTTP handlers:
43
+ //
44
+ // http.Handle("/api", auth.RequireAuth(handler))
45
+ //
46
+ package auth
47
+ ```
48
+
49
+ **Example (single file)**:
50
+ ```go
51
+ // Package mathutil provides mathematical utility functions
52
+ // for common operations not found in the standard library.
53
+ package mathutil
54
+ ```
55
+
56
+ ### GOL.2.6.2: Function/Method Comment Format
57
+
58
+ **Rule**: Document all exported functions and methods with comments that start with the function name.
59
+
60
+ **Rationale**: Godoc extracts these comments to generate documentation. Starting with the function name makes it clear what's being documented.
61
+
62
+ **Format**:
63
+ - Start with the function/method name
64
+ - Write complete sentences
65
+ - Explain what the function does, parameters, and return values
66
+ - Document error conditions
67
+ - Use blank lines to separate paragraphs
68
+
69
+ **Example**:
70
+ ```go
71
+ // NewClient creates a new HTTP client with the given configuration.
72
+ // It returns an error if the configuration is invalid or if the
73
+ // client cannot be initialized.
74
+ //
75
+ // The client automatically handles retries, timeouts, and connection
76
+ // pooling based on the provided configuration.
77
+ func NewClient(config *Config) (*Client, error) {
78
+ // Implementation
79
+ }
80
+
81
+ // Get retrieves a resource by ID from the server.
82
+ // It returns ErrNotFound if the resource doesn't exist,
83
+ // or ErrUnauthorized if authentication fails.
84
+ func (c *Client) Get(ctx context.Context, id string) (*Resource, error) {
85
+ // Implementation
86
+ }
87
+ ```
88
+
89
+ **Bad Example**:
90
+ ```go
91
+ // Creates a new client // Missing function name
92
+ func NewClient(config *Config) (*Client, error) {
93
+ // Implementation
94
+ }
95
+
96
+ // get resource // Not a complete sentence, missing details
97
+ func (c *Client) Get(ctx context.Context, id string) (*Resource, error) {
98
+ // Implementation
99
+ }
100
+ ```
101
+
102
+ ### GOL.2.6.3: Example Test Functions for Godoc
103
+
104
+ **Rule**: Use Example test functions to provide executable documentation.
105
+
106
+ **Rationale**: Example tests appear in godoc and are verified by `go test`, ensuring documentation stays accurate.
107
+
108
+ **Format**:
109
+ - Function name: `Example`, `Example<FunctionName>`, or `Example<Type>_<Method>`
110
+ - Use `// Output:` comment to specify expected output
111
+ - Examples are executed as tests
112
+
113
+ **Example**:
114
+ ```go
115
+ package mathutil_test
116
+
117
+ import (
118
+ "fmt"
119
+ "myproject/mathutil"
120
+ )
121
+
122
+ // Example demonstrates basic usage of the package.
123
+ func Example() {
124
+ result := mathutil.Add(2, 3)
125
+ fmt.Println(result)
126
+ // Output: 5
127
+ }
128
+
129
+ // ExampleAdd demonstrates the Add function with negative numbers.
130
+ func ExampleAdd() {
131
+ result := mathutil.Add(-2, 3)
132
+ fmt.Println(result)
133
+ // Output: 1
134
+ }
135
+
136
+ // ExampleCalculator_Multiply demonstrates the Multiply method.
137
+ func ExampleCalculator_Multiply() {
138
+ calc := mathutil.NewCalculator()
139
+ result := calc.Multiply(4, 5)
140
+ fmt.Println(result)
141
+ // Output: 20
142
+ }
143
+ ```
144
+
145
+ ### GOL.2.6.4: Godoc Compatibility Requirements
146
+
147
+ **Rule**: Write comments that render well in godoc and follow godoc conventions.
148
+
149
+ **Rationale**: Godoc is the standard documentation tool for Go. Following its conventions ensures documentation is accessible and well-formatted.
150
+
151
+ **Guidelines**:
152
+ - Use blank lines to separate paragraphs
153
+ - Indent code blocks with a single tab or 4 spaces
154
+ - Use `//` for single-line comments, not `/* */`
155
+ - Link to other symbols with just their name (godoc auto-links)
156
+ - Use headings sparingly (godoc doesn't support markdown)
157
+
158
+ **Example**:
159
+ ```go
160
+ // Server represents an HTTP server with graceful shutdown support.
161
+ //
162
+ // The server automatically handles:
163
+ //
164
+ // - Request logging
165
+ // - Panic recovery
166
+ // - Graceful shutdown
167
+ //
168
+ // Create a new server with NewServer and start it with Start:
169
+ //
170
+ // server := NewServer(config)
171
+ // if err := server.Start(); err != nil {
172
+ // log.Fatal(err)
173
+ // }
174
+ //
175
+ // The server can be stopped gracefully with Stop, which waits for
176
+ // active connections to complete before shutting down.
177
+ type Server struct {
178
+ // Implementation
179
+ }
180
+ ```
181
+
182
+ ### GOL.2.6.5: README.md Requirements
183
+
184
+ **Rule**: Every Go module must have a comprehensive README.md file.
185
+
186
+ **Rationale**: README.md is the first thing users see. It should provide all essential information for getting started.
187
+
188
+ **Required Sections**:
189
+ 1. **Title and Description**: What the project does
190
+ 2. **Installation**: How to install/import the package
191
+ 3. **Quick Start**: Basic usage example
192
+ 4. **Documentation**: Link to godoc or detailed docs
193
+ 5. **Examples**: Common use cases
194
+ 6. **Contributing**: How to contribute (if applicable)
195
+ 7. **License**: License information
196
+
197
+ **Example README.md**:
198
+ ```markdown
199
+ # MyProject
200
+
201
+ A high-performance HTTP client for Go with automatic retries and circuit breaking.
202
+
203
+ ## Installation
204
+
205
+ ```bash
206
+ go get github.com/mycompany/myproject
207
+ ```
208
+
209
+ ## Quick Start
210
+
211
+ ```go
212
+ package main
213
+
214
+ import (
215
+ "context"
216
+ "github.com/mycompany/myproject"
217
+ )
218
+
219
+ func main() {
220
+ client := myproject.NewClient(&myproject.Config{
221
+ Timeout: 30 * time.Second,
222
+ Retries: 3,
223
+ })
224
+
225
+ resp, err := client.Get(context.Background(), "https://api.example.com")
226
+ if err != nil {
227
+ log.Fatal(err)
228
+ }
229
+ defer resp.Body.Close()
230
+ }
231
+ ```
232
+
233
+ ## Documentation
234
+
235
+ Full documentation is available at [pkg.go.dev](https://pkg.go.dev/github.com/mycompany/myproject).
236
+
237
+ ## License
238
+
239
+ MIT License - see LICENSE file for details.
240
+ ```
241
+
242
+ ## Additional Best Practices
243
+
244
+ **Type Documentation**:
245
+ ```go
246
+ // User represents an authenticated user in the system.
247
+ // It contains both public profile information and internal metadata.
248
+ type User struct {
249
+ ID string // Unique identifier
250
+ Email string // User's email address
251
+ }
252
+ ```
253
+
254
+ **Constant Documentation**:
255
+ ```go
256
+ // HTTP status codes for API responses.
257
+ const (
258
+ StatusOK = 200 // Request succeeded
259
+ StatusCreated = 201 // Resource created
260
+ StatusError = 500 // Internal server error
261
+ )
262
+ ```
263
+
264
+ ## References
265
+
266
+ - [Godoc: Documenting Go Code](https://go.dev/blog/godoc)
267
+ - [Effective Go - Commentary](https://go.dev/doc/effective_go#commentary)
268
+ - [Go Doc Comments](https://go.dev/doc/comment)
269
+