[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7DNBM0MXCQD36JBENK61C4Y":3,"skill-same:01M7DNBM0MXCQD36JBENK61C4Y":57},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":15,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":13,"repositoryHtmlUrl":27,"repositoryHomepageUrl":28,"ownerHtmlUrl":29,"ownerBlogUrl":30,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M7DNBM0MXCQD36JBENK61C4Y","github-copilot-go",null,"Review idiomatic Go code, HTTP request ownership, I\u002FO reuse and API hygiene. Load as an optional review checklist, not as an always-on instruction rule.","Cratis\u002FFundamentals.Go","Cratis","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F16456213?v=4","01M6BXRH290K4C8RS4PTKK3HXQ","01M7DN6YCMASAFGKYBBH3C1Z6E",0,"MIT","https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fgithub-copilot-go\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fgithub-copilot-go\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: github-copilot-go\ndescription: Review idiomatic Go code, HTTP request ownership, I\u002FO reuse and API hygiene. Load as an optional review checklist, not as an always-on instruction rule.\n---\n\n> Third-party guidance. Repository rules `.cratis\u002Fai\u002Frules\u002Fgo.md` and\n> `go-cratis-parity.md` take precedence where they conflict (e.g. Go minimum\n> version from go.mod, no `pkg\u002F`, functional options only when warranted).\n\n# Local review qualifications\n\n- Prefer a small public surface, but preserve intentional extension interfaces.\n  Singular package names and one-to-three-method interfaces are not hard limits.\n- Wrap with `%w` only when callers should depend on the cause. Small value\n  receivers\u002Fparameters can still share slices, maps and pointers; size alone does\n  not imply immutability. Never copy used synchronization values.\n- Before pooling or optimizing, measure. Before replaying HTTP requests, establish\n  idempotency, body recreation, cancellation, ownership and bounded payload size.\n- `io.Pipe` producers need cancellation, reader\u002Fwriter closure and joining on all\n  paths, including an early HTTP failure. Check multipart writer Close errors.\n- Preserve Cratis response envelopes\u002Froutes rather than adopting generic handler\n  snippets as wire contracts. New dependencies\u002Ftools still require justification.\n\n# Go Development Instructions\n\nFollow idiomatic Go practices and community standards when writing Go code. These instructions are based on [Effective Go](https:\u002F\u002Fgo.dev\u002Fdoc\u002Feffective_go), [Go Code Review Comments](https:\u002F\u002Fgo.dev\u002Fwiki\u002FCodeReviewComments), and [Google's Go Style Guide](https:\u002F\u002Fgoogle.github.io\u002Fstyleguide\u002Fgo\u002F).\n\n## General Instructions\n\n- Write simple, clear, and idiomatic Go code\n- Favor clarity and simplicity over cleverness\n- Follow the principle of least surprise\n- Keep the happy path left-aligned (minimize indentation)\n- Return early to reduce nesting\n- Prefer early return over if-else chains; use `if condition { return }` pattern to avoid else blocks\n- Make the zero value useful\n- Write self-documenting code with clear, descriptive names\n- Document exported types, functions, methods, and packages\n- Use Go modules for dependency management\n- Leverage the Go standard library instead of reinventing the wheel (e.g., use `strings.Builder` for string concatenation, `filepath.Join` for path construction)\n- Prefer standard library solutions over custom implementations when functionality exists\n- Write comments in English by default; translate only upon user request\n- Avoid using emoji in code and comments\n\n## Naming Conventions\n\n### Packages\n\n- Use lowercase, single-word package names\n- Avoid underscores, hyphens, or mixedCaps\n- Choose names that describe what the package provides, not what it contains\n- Avoid generic names like `util`, `common`, or `base`\n- Package names should be singular, not plural\n\n#### Package declarations\n\nKeep exactly one package clause. Match the package in the directory, allowing\nexternal `_test` packages; preserve leading license comments and build constraints.\n\n### Variables and Functions\n\n- Use mixedCaps or MixedCaps (camelCase) rather than underscores\n- Keep names short but descriptive\n- Use single-letter variables only for very short scopes (like loop indices)\n- Exported names start with a capital letter\n- Unexported names start with a lowercase letter\n- Avoid stuttering (e.g., avoid `http.HTTPServer`, prefer `http.Server`)\n\n### Interfaces\n\n- Name interfaces with -er suffix when possible (e.g., `Reader`, `Writer`, `Formatter`)\n- Single-method interfaces should be named after the method (e.g., `Read` → `Reader`)\n- Keep interfaces small and focused\n\n### Constants\n\n- Use MixedCaps for exported constants\n- Use mixedCaps for unexported constants\n- Group related constants using `const` blocks\n- Consider using typed constants for better type safety\n\n## Code Style and Formatting\n\n### Formatting\n\n- Always use `gofmt` to format code\n- Use `goimports` to manage imports automatically\n- Keep line length reasonable (no hard limit, but consider readability)\n- Add blank lines to separate logical groups of code\n\n### Comments\n\n- Strive for self-documenting code; prefer clear variable names, function names, and code structure over comments\n- Write comments only when necessary to explain complex logic, business rules, or non-obvious behavior\n- Write comments in complete sentences in English by default\n- Translate comments to other languages only upon specific user request\n- Start sentences with the name of the thing being described\n- Package comments should start with \"Package [name]\"\n- Use line comments (`\u002F\u002F`) for most comments\n- Use block comments (`\u002F* *\u002F`) sparingly, mainly for package documentation\n- Document why, not what, unless the what is complex\n- Avoid using emoji in comments and code\n\n### Error Handling\n\n- Check errors immediately after the function call\n- Don't ignore errors using `_` unless you have a good reason (document why)\n- Wrap errors with context using `fmt.Errorf` with `%w` verb\n- Create custom error types when you need to check for specific errors\n- Place error returns as the last return value\n- Name error variables `err`\n- Keep error messages lowercase and don't end with punctuation\n\n## Architecture and Project Structure\n\n### Package Organization\n\n- Follow standard Go project layout conventions\n- Keep `main` packages in `cmd\u002F` directory\n- Put public packages at responsibility-based module paths, without `pkg\u002F`; use `internal\u002F` for implementation-only packages\n- Use `internal\u002F` for packages that shouldn't be imported by external projects\n- Group related functionality into packages\n- Avoid circular dependencies\n\n### Dependency Management\n\n- Use Go modules (`go.mod` and `go.sum`)\n- Keep dependencies minimal\n- Regularly update dependencies for security patches\n- Use `go mod tidy` to clean up unused dependencies\n- Vendor dependencies only when necessary\n\n## Type Safety and Language Features\n\n### Type Definitions\n\n- Define types to add meaning and type safety\n- Use struct tags for JSON, XML, database mappings\n- Prefer explicit type conversions\n- Use type assertions carefully and check the second return value\n- Prefer generics over unconstrained types; when an unconstrained type is truly needed, use the predeclared alias `any` instead of `interface{}` (Go 1.18+)\n\n### Pointers vs Values\n\n- Use pointer receivers for large structs or when you need to modify the receiver\n- Use value receivers for small structs and when immutability is desired\n- Use pointer parameters when you need to modify the argument or for large structs\n- Use value parameters for small structs and when you want to prevent modification\n- Be consistent within a type's method set\n- Consider the zero value when choosing pointer vs value receivers\n\n### Interfaces and Composition\n\n- Accept interfaces, return concrete types\n- Keep interfaces small (1-3 methods is ideal)\n- Use embedding for composition\n- Define interfaces close to where they're used, not where they're implemented\n- Don't export interfaces unless necessary\n\n## Concurrency\n\n### Goroutines\n\n- Be cautious about creating goroutines in libraries; prefer letting the caller control concurrency\n- If you must create goroutines in libraries, provide clear documentation and cleanup mechanisms\n- Always know how a goroutine will exit\n- Use `sync.WaitGroup` or channels to wait for goroutines\n- Avoid goroutine leaks by ensuring cleanup\n\n### Channels\n\n- Use channels to communicate between goroutines\n- Don't communicate by sharing memory; share memory by communicating\n- Close channels from the sender side, not the receiver\n- Use buffered channels when you know the capacity\n- Use `select` for non-blocking operations\n\n### Synchronization\n\n- Use `sync.Mutex` for protecting shared state\n- Keep critical sections small\n- Use `sync.RWMutex` when you have many readers\n- Choose between channels and mutexes based on the use case: use channels for communication, mutexes for protecting state\n- Use `sync.Once` for one-time initialization\n- WaitGroup usage by Go version:\n\t- If `go >= 1.25` in `go.mod`, use the new `WaitGroup.Go` method ([documentation](https:\u002F\u002Fpkg.go.dev\u002Fsync#WaitGroup)):\n\t\t```go\n\t\tvar wg sync.WaitGroup\n\t\twg.Go(task1)\n\t\twg.Go(task2)\n\t\twg.Wait()\n\t\t```\n\t- If `go \u003C 1.25`, use the classic `Add`\u002F`Done` pattern\n\n## Error Handling Patterns\n\n### Creating Errors\n\n- Use `errors.New` for simple static errors\n- Use `fmt.Errorf` for dynamic errors\n- Create custom error types for domain-specific errors\n- Export error variables for sentinel errors\n- Use `errors.Is` and `errors.As` for error checking\n\n### Error Propagation\n\n- Add context when propagating errors up the stack\n- Don't log and return errors (choose one)\n- Handle errors at the appropriate level\n- Consider using structured errors for better debugging\n\n## API Design\n\n### HTTP Handlers\n\n- Use `http.HandlerFunc` for simple handlers\n- Implement `http.Handler` for handlers that need state\n- Use middleware for cross-cutting concerns\n- Set appropriate status codes and headers\n- Handle errors gracefully and return appropriate error responses\n- Router usage by Go version:\n\t- If `go >= 1.22`, prefer the enhanced `net\u002Fhttp` `ServeMux` with pattern-based routing and method matching\n\t- If `go \u003C 1.22`, use the classic `ServeMux` and handle methods\u002Fpaths manually (or use a third-party router when justified)\n\n### JSON APIs\n\n- Use struct tags to control JSON marshaling\n- Validate input data\n- Use pointers for optional fields\n- Consider using `json.RawMessage` for delayed parsing\n- Handle JSON errors appropriately\n\n### HTTP Clients\n\n- Keep the client struct focused on configuration and dependencies only (e.g., base URL, `*http.Client`, auth, default headers). It must not store any per-request state\n- Do not store or cache `*http.Request` inside the client struct, and do not persist request-specific state across calls; instead, construct a fresh request per method invocation\n- Methods should accept `context.Context` and input parameters, assemble the `*http.Request` locally (or via a short-lived builder\u002Fhelper created per call), then call `c.httpClient.Do(req)`\n- If request-building logic is reused, factor it into unexported helper functions or a per-call builder type; never keep `http.Request` (URL params, body, headers) as fields on the long-lived client\n- Ensure the underlying `*http.Client` is configured (timeouts, transport) and is safe for concurrent use; avoid mutating `Transport` after first use\n- Always set headers on the request instance you’re sending, and close response bodies (`defer resp.Body.Close()`), handling errors appropriately\n\n## Performance Optimization\n\n### Memory Management\n\n- Minimize allocations in hot paths\n- Reuse objects when possible (consider `sync.Pool`)\n- Use value receivers for small structs\n- Preallocate slices when size is known\n- Avoid unnecessary string conversions\n\n### I\u002FO: Readers and Buffers\n\n- Most `io.Reader` streams are consumable once; reading advances state. Do not assume a reader can be re-read without special handling\n- If you must read data multiple times, buffer it once and recreate readers on demand:\n\t- Use `io.ReadAll` (or a limited read) to obtain `[]byte`, then create fresh readers via `bytes.NewReader(buf)` or `bytes.NewBuffer(buf)` for each reuse\n\t- For strings, use `strings.NewReader(s)`; you can `Seek(0, io.SeekStart)` on `*bytes.Reader` to rewind\n- For HTTP requests, do not reuse a consumed `req.Body`. Instead:\n\t- Keep the original payload as `[]byte` and set `req.Body = io.NopCloser(bytes.NewReader(buf))` before each send\n\t- Prefer configuring `req.GetBody` so the transport can recreate the body for redirects\u002Fretries: `req.GetBody = func() (io.ReadCloser, error) { return io.NopCloser(bytes.NewReader(buf)), nil }`\n- To duplicate a stream while reading, use `io.TeeReader` (copy to a buffer while passing through) or write to multiple sinks with `io.MultiWriter`\n- Reusing buffered readers: call `(*bufio.Reader).Reset(r)` to attach to a new underlying reader; do not expect it to “rewind” unless the source supports seeking\n- For large payloads, avoid unbounded buffering; consider streaming, `io.LimitReader`, or on-disk temporary storage to control memory\n\n- Use `io.Pipe` to stream without buffering the whole payload:\n\t- Write to `*io.PipeWriter` in a separate goroutine while the reader consumes\n\t- Always close the writer; use `CloseWithError(err)` on failures\n\t- `io.Pipe` is for streaming, not rewinding or making readers reusable\n\n- **Warning:** When using `io.Pipe` (especially with multipart writers), all writes must be performed in strict, sequential order. Do not write concurrently or out of order—multipart boundaries and chunk order must be preserved. Out-of-order or parallel writes can corrupt the stream and result in errors.\n\n- Streaming multipart\u002Fform-data with `io.Pipe`:\n\t- `pr, pw := io.Pipe()`; `mw := multipart.NewWriter(pw)`; use `pr` as the HTTP request body\n\t- Set `Content-Type` to `mw.FormDataContentType()`\n\t- In a goroutine: write all parts to `mw` in the correct order; on error `pw.CloseWithError(err)`; on success `mw.Close()` then `pw.Close()`\n\t- Do not store request\u002Fin-flight form state on a long-lived client; build per call\n\t- Streamed bodies are not rewindable; for retries\u002Fredirects, buffer small payloads or provide `GetBody`\n\n### Profiling\n\n- Use built-in profiling tools (`pprof`)\n- Benchmark critical code paths\n- Profile before optimizing\n- Focus on algorithmic improvements first\n- Consider using `testing.B` for benchmarks\n\n## Testing\n\n### Test Organization\n\n- Keep tests in the same package (white-box testing)\n- Use `_test` package suffix for black-box testing\n- Name test files with `_test.go` suffix\n- Place test files next to the code they test\n\n### Writing Tests\n\n- Use table-driven tests for multiple test cases\n- Name tests descriptively using `Test_functionName_scenario`\n- Use subtests with `t.Run` for better organization\n- Test both success and error cases\n- Consider using `testify` or similar libraries when they add value, but don't over-complicate simple tests\n\n### Test Helpers\n\n- Mark helper functions with `t.Helper()`\n- Create test fixtures for complex setup\n- Use `testing.TB` interface for functions used in tests and benchmarks\n- Clean up resources using `t.Cleanup()`\n\n## Security Best Practices\n\n### Input Validation\n\n- Validate all external input\n- Use strong typing to prevent invalid states\n- Use parameterized SQL queries; do not concatenate or rely on sanitizing untrusted values\n- Be careful with file paths from user input\n- Use context-appropriate HTML escaping, SQL parameters, and explicit subprocess arguments instead of shell interpolation\n\n### Cryptography\n\n- Use standard library crypto packages\n- Don't implement your own cryptography\n- Use crypto\u002Frand for random number generation\n- Store passwords using bcrypt, scrypt, or argon2 (consider golang.org\u002Fx\u002Fcrypto for additional options)\n- Use TLS for network communication\n\n## Documentation\n\n### Code Documentation\n\n- Prioritize self-documenting code through clear naming and structure\n- Document all exported symbols with clear, concise explanations\n- Start documentation with the symbol name\n- Write documentation in English by default\n- Use examples in documentation when helpful\n- Keep documentation close to code\n- Update documentation when code changes\n- Avoid emoji in documentation and comments\n\n### README and Documentation Files\n\n- Include clear setup instructions\n- Document dependencies and requirements\n- Provide usage examples\n- Document configuration options\n- Include troubleshooting section\n\n## Tools and Development Workflow\n\n### Essential Tools\n\n- `go fmt`: Format code\n- `go vet`: Find suspicious constructs\n- `golangci-lint`: Additional linting (golint is deprecated)\n- `go test`: Run tests\n- `go mod`: Manage dependencies\n- `go generate`: Code generation\n\n### Development Practices\n\n- Run tests before committing\n- Use pre-commit hooks for formatting and linting\n- Keep commits focused and atomic\n- Write meaningful commit messages\n- Review diffs before committing\n\n## Common Pitfalls to Avoid\n\n- Not checking errors\n- Ignoring race conditions\n- Creating goroutine leaks\n- Not using defer for cleanup\n- Modifying maps concurrently\n- Not understanding nil interfaces vs nil pointers\n- Forgetting to close resources (files, connections)\n- Using global variables unnecessarily\n- Overusing unconstrained types (e.g., `any`); prefer specific types or generic type parameters with constraints. If an unconstrained type is required, use `any` rather than `interface{}`\n- Not considering the zero value of types\n","> Third-party guidance. Repository rules `.cratis\u002Fai\u002Frules\u002Fgo.md` and\n> `go-cratis-parity.md` take precedence where they conflict (e.g. Go minimum\n> version from go.mod, no `pkg\u002F`, functional options only when warranted).\n\n# Local review qualifications\n\n- Prefer a small public surface, but preserve intentional extension interfaces.\n  Singular package names and one-to-three-method interfaces are not hard limits.\n- Wrap with `%w` only when callers should depend on the cause. Small value\n  receivers\u002Fparameters can still share slices, maps and pointers; size alone does\n  not imply immutability. Never copy used synchronization values.\n- Before pooling or optimizing, measure. Before replaying HTTP requests, establish\n  idempotency, body recreation, cancellation, ownership and bounded payload size.\n- `io.Pipe` producers need cancellation, reader\u002Fwriter closure and joining on all\n  paths, including an early HTTP failure. Check multipart writer Close errors.\n- Preserve Cratis response envelopes\u002Froutes rather than adopting generic handler\n  snippets as wire contracts. New dependencies\u002Ftools still require justification.\n\n# Go Development Instructions\n\nFollow idiomatic Go practices and community standards when writing Go code. These instructions are based on [Effective Go](https:\u002F\u002Fgo.dev\u002Fdoc\u002Feffective_go), [Go Code Review Comments](https:\u002F\u002Fgo.dev\u002Fwiki\u002FCodeReviewComments), and [Google's Go Style Guide](https:\u002F\u002Fgoogle.github.io\u002Fstyleguide\u002Fgo\u002F).\n\n## General Instructions\n\n- Write simple, clear, and idiomatic Go code\n- Favor clarity and simplicity over cleverness\n- Follow the principle of least surprise\n- Keep the happy path left-aligned (minimize indentation)\n- Return early to reduce nesting\n- Prefer early return over if-else chains; use `if condition { return }` pattern to avoid else blocks\n- Make the zero value useful\n- Write self-documenting code with clear, descriptive names\n- Document exported types, functions, methods, and packages\n- Use Go modules for dependency management\n- Leverage the Go standard library instead of reinventing the wheel (e.g., use `strings.Builder` for string concatenation, `filepath.Join` for path construction)\n- Prefer standard library solutions over custom implementations when functionality exists\n- Write comments in English by default; translate only upon user request\n- Avoid using emoji in code and comments\n\n## Naming Conventions\n\n### Packages\n\n- Use lowercase, single-word package names\n- Avoid underscores, hyphens, or mixedCaps\n- Choose names that describe what the package provides, not what it contains\n- Avoid generic names like `util`, `common`, or `base`\n- Package names should be singular, not plural\n\n#### Package declarations\n\nKeep exactly one package clause. Match the package in the directory, allowing\nexternal `_test` packages; preserve leading license comments and build constraints.\n\n### Variables and Functions\n\n- Use mixedCaps or MixedCaps (camelCase) rather than underscores\n- Keep names short but descriptive\n- Use single-letter variables only for very short scopes (like loop indices)\n- Exported names start with a capital letter\n- Unexported names start with a lowercase letter\n- Avoid stuttering (e.g., avoid `http.HTTPServer`, prefer `http.Server`)\n\n### Interfaces\n\n- Name interfaces with -er suffix when possible (e.g., `Reader`, `Writer`, `Formatter`)\n- Single-method interfaces should be named after the method (e.g., `Read` → `Reader`)\n- Keep interfaces small and focused\n\n### Constants\n\n- Use MixedCaps for exported constants\n- Use mixedCaps for unexported constants\n- Group related constants using `const` blocks\n- Consider using typed constants for better type safety\n\n## Code Style and Formatting\n\n### Formatting\n\n- Always use `gofmt` to format code\n- Use `goimports` to manage imports automatically\n- Keep line length reasonable (no hard limit, but consider readability)\n- Add blank lines to separate logical groups of code\n\n### Comments\n\n- Strive for self-documenting code; prefer clear variable names, function names, and code structure over comments\n- Write comments only when necessary to explain complex logic, business rules, or non-obvious behavior\n- Write comments in complete sentences in English by default\n- Translate comments to other languages only upon specific user request\n- Start sentences with the name of the thing being described\n- Package comments should start with \"Package [name]\"\n- Use line comments (`\u002F\u002F`) for most comments\n- Use block comments (`\u002F* *\u002F`) sparingly, mainly for package documentation\n- Document why, not what, unless the what is complex\n- Avoid using emoji in comments and code\n\n### Error Handling\n\n- Check errors immediately after the function call\n- Don't ignore errors using `_` unless you have a good reason (document why)\n- Wrap errors with context using `fmt.Errorf` with `%w` verb\n- Create custom error types when you need to check for specific errors\n- Place error returns as the last return value\n- Name error variables `err`\n- Keep error messages lowercase and don't end with punctuation\n\n## Architecture and Project Structure\n\n### Package Organization\n\n- Follow standard Go project layout conventions\n- Keep `main` packages in `cmd\u002F` directory\n- Put public packages at responsibility-based module paths, without `pkg\u002F`; use `internal\u002F` for implementation-only packages\n- Use `internal\u002F` for packages that shouldn't be imported by external projects\n- Group related functionality into packages\n- Avoid circular dependencies\n\n### Dependency Management\n\n- Use Go modules (`go.mod` and `go.sum`)\n- Keep dependencies minimal\n- Regularly update dependencies for security patches\n- Use `go mod tidy` to clean up unused dependencies\n- Vendor dependencies only when necessary\n\n## Type Safety and Language Features\n\n### Type Definitions\n\n- Define types to add meaning and type safety\n- Use struct tags for JSON, XML, database mappings\n- Prefer explicit type conversions\n- Use type assertions carefully and check the second return value\n- Prefer generics over unconstrained types; when an unconstrained type is truly needed, use the predeclared alias `any` instead of `interface{}` (Go 1.18+)\n\n### Pointers vs Values\n\n- Use pointer receivers for large structs or when you need to modify the receiver\n- Use value receivers for small structs and when immutability is desired\n- Use pointer parameters when you need to modify the argument or for large structs\n- Use value parameters for small structs and when you want to prevent modification\n- Be consistent within a type's method set\n- Consider the zero value when choosing pointer vs value receivers\n\n### Interfaces and Composition\n\n- Accept interfaces, return concrete types\n- Keep interfaces small (1-3 methods is ideal)\n- Use embedding for composition\n- Define interfaces close to where they're used, not where they're implemented\n- Don't export interfaces unless necessary\n\n## Concurrency\n\n### Goroutines\n\n- Be cautious about creating goroutines in libraries; prefer letting the caller control concurrency\n- If you must create goroutines in libraries, provide clear documentation and cleanup mechanisms\n- Always know how a goroutine will exit\n- Use `sync.WaitGroup` or channels to wait for goroutines\n- Avoid goroutine leaks by ensuring cleanup\n\n### Channels\n\n- Use channels to communicate between goroutines\n- Don't communicate by sharing memory; share memory by communicating\n- Close channels from the sender side, not the receiver\n- Use buffered channels when you know the capacity\n- Use `select` for non-blocking operations\n\n### Synchronization\n\n- Use `sync.Mutex` for protecting shared state\n- Keep critical sections small\n- Use `sync.RWMutex` when you have many readers\n- Choose between channels and mutexes based on the use case: use channels for communication, mutexes for protecting state\n- Use `sync.Once` for one-time initialization\n- WaitGroup usage by Go version:\n\t- If `go >= 1.25` in `go.mod`, use the new `WaitGroup.Go` method ([documentation](https:\u002F\u002Fpkg.go.dev\u002Fsync#WaitGroup)):\n\t\t```go\n\t\tvar wg sync.WaitGroup\n\t\twg.Go(task1)\n\t\twg.Go(task2)\n\t\twg.Wait()\n\t\t```\n\t- If `go \u003C 1.25`, use the classic `Add`\u002F`Done` pattern\n\n## Error Handling Patterns\n\n### Creating Errors\n\n- Use `errors.New` for simple static errors\n- Use `fmt.Errorf` for dynamic errors\n- Create custom error types for domain-specific errors\n- Export error variables for sentinel errors\n- Use `errors.Is` and `errors.As` for error checking\n\n### Error Propagation\n\n- Add context when propagating errors up the stack\n- Don't log and return errors (choose one)\n- Handle errors at the appropriate level\n- Consider using structured errors for better debugging\n\n## API Design\n\n### HTTP Handlers\n\n- Use `http.HandlerFunc` for simple handlers\n- Implement `http.Handler` for handlers that need state\n- Use middleware for cross-cutting concerns\n- Set appropriate status codes and headers\n- Handle errors gracefully and return appropriate error responses\n- Router usage by Go version:\n\t- If `go >= 1.22`, prefer the enhanced `net\u002Fhttp` `ServeMux` with pattern-based routing and method matching\n\t- If `go \u003C 1.22`, use the classic `ServeMux` and handle methods\u002Fpaths manually (or use a third-party router when justified)\n\n### JSON APIs\n\n- Use struct tags to control JSON marshaling\n- Validate input data\n- Use pointers for optional fields\n- Consider using `json.RawMessage` for delayed parsing\n- Handle JSON errors appropriately\n\n### HTTP Clients\n\n- Keep the client struct focused on configuration and dependencies only (e.g., base URL, `*http.Client`, auth, default headers). It must not store any per-request state\n- Do not store or cache `*http.Request` inside the client struct, and do not persist request-specific state across calls; instead, construct a fresh request per method invocation\n- Methods should accept `context.Context` and input parameters, assemble the `*http.Request` locally (or via a short-lived builder\u002Fhelper created per call), then call `c.httpClient.Do(req)`\n- If request-building logic is reused, factor it into unexported helper functions or a per-call builder type; never keep `http.Request` (URL params, body, headers) as fields on the long-lived client\n- Ensure the underlying `*http.Client` is configured (timeouts, transport) and is safe for concurrent use; avoid mutating `Transport` after first use\n- Always set headers on the request instance you’re sending, and close response bodies (`defer resp.Body.Close()`), handling errors appropriately\n\n## Performance Optimization\n\n### Memory Management\n\n- Minimize allocations in hot paths\n- Reuse objects when possible (consider `sync.Pool`)\n- Use value receivers for small structs\n- Preallocate slices when size is known\n- Avoid unnecessary string conversions\n\n### I\u002FO: Readers and Buffers\n\n- Most `io.Reader` streams are consumable once; reading advances state. Do not assume a reader can be re-read without special handling\n- If you must read data multiple times, buffer it once and recreate readers on demand:\n\t- Use `io.ReadAll` (or a limited read) to obtain `[]byte`, then create fresh readers via `bytes.NewReader(buf)` or `bytes.NewBuffer(buf)` for each reuse\n\t- For strings, use `strings.NewReader(s)`; you can `Seek(0, io.SeekStart)` on `*bytes.Reader` to rewind\n- For HTTP requests, do not reuse a consumed `req.Body`. Instead:\n\t- Keep the original payload as `[]byte` and set `req.Body = io.NopCloser(bytes.NewReader(buf))` before each send\n\t- Prefer configuring `req.GetBody` so the transport can recreate the body for redirects\u002Fretries: `req.GetBody = func() (io.ReadCloser, error) { return io.NopCloser(bytes.NewReader(buf)), nil }`\n- To duplicate a stream while reading, use `io.TeeReader` (copy to a buffer while passing through) or write to multiple sinks with `io.MultiWriter`\n- Reusing buffered readers: call `(*bufio.Reader).Reset(r)` to attach to a new underlying reader; do not expect it to “rewind” unless the source supports seeking\n- For large payloads, avoid unbounded buffering; consider streaming, `io.LimitReader`, or on-disk temporary storage to control memory\n\n- Use `io.Pipe` to stream without buffering the whole payload:\n\t- Write to `*io.PipeWriter` in a separate goroutine while the reader consumes\n\t- Always close the writer; use `CloseWithError(err)` on failures\n\t- `io.Pipe` is for streaming, not rewinding or making readers reusable\n\n- **Warning:** When using `io.Pipe` (especially with multipart writers), all writes must be performed in strict, sequential order. Do not write concurrently or out of order—multipart boundaries and chunk order must be preserved. Out-of-order or parallel writes can corrupt the stream and result in errors.\n\n- Streaming multipart\u002Fform-data with `io.Pipe`:\n\t- `pr, pw := io.Pipe()`; `mw := multipart.NewWriter(pw)`; use `pr` as the HTTP request body\n\t- Set `Content-Type` to `mw.FormDataContentType()`\n\t- In a goroutine: write all parts to `mw` in the correct order; on error `pw.CloseWithError(err)`; on success `mw.Close()` then `pw.Close()`\n\t- Do not store request\u002Fin-flight form state on a long-lived client; build per call\n\t- Streamed bodies are not rewindable; for retries\u002Fredirects, buffer small payloads or provide `GetBody`\n\n### Profiling\n\n- Use built-in profiling tools (`pprof`)\n- Benchmark critical code paths\n- Profile before optimizing\n- Focus on algorithmic improvements first\n- Consider using `testing.B` for benchmarks\n\n## Testing\n\n### Test Organization\n\n- Keep tests in the same package (white-box testing)\n- Use `_test` package suffix for black-box testing\n- Name test files with `_test.go` suffix\n- Place test files next to the code they test\n\n### Writing Tests\n\n- Use table-driven tests for multiple test cases\n- Name tests descriptively using `Test_functionName_scenario`\n- Use subtests with `t.Run` for better organization\n- Test both success and error cases\n- Consider using `testify` or similar libraries when they add value, but don't over-complicate simple tests\n\n### Test Helpers\n\n- Mark helper functions with `t.Helper()`\n- Create test fixtures for complex setup\n- Use `testing.TB` interface for functions used in tests and benchmarks\n- Clean up resources using `t.Cleanup()`\n\n## Security Best Practices\n\n### Input Validation\n\n- Validate all external input\n- Use strong typing to prevent invalid states\n- Use parameterized SQL queries; do not concatenate or rely on sanitizing untrusted values\n- Be careful with file paths from user input\n- Use context-appropriate HTML escaping, SQL parameters, and explicit subprocess arguments instead of shell interpolation\n\n### Cryptography\n\n- Use standard library crypto packages\n- Don't implement your own cryptography\n- Use crypto\u002Frand for random number generation\n- Store passwords using bcrypt, scrypt, or argon2 (consider golang.org\u002Fx\u002Fcrypto for additional options)\n- Use TLS for network communication\n\n## Documentation\n\n### Code Documentation\n\n- Prioritize self-documenting code through clear naming and structure\n- Document all exported symbols with clear, concise explanations\n- Start documentation with the symbol name\n- Write documentation in English by default\n- Use examples in documentation when helpful\n- Keep documentation close to code\n- Update documentation when code changes\n- Avoid emoji in documentation and comments\n\n### README and Documentation Files\n\n- Include clear setup instructions\n- Document dependencies and requirements\n- Provide usage examples\n- Document configuration options\n- Include troubleshooting section\n\n## Tools and Development Workflow\n\n### Essential Tools\n\n- `go fmt`: Format code\n- `go vet`: Find suspicious constructs\n- `golangci-lint`: Additional linting (golint is deprecated)\n- `go test`: Run tests\n- `go mod`: Manage dependencies\n- `go generate`: Code generation\n\n### Development Practices\n\n- Run tests before committing\n- Use pre-commit hooks for formatting and linting\n- Keep commits focused and atomic\n- Write meaningful commit messages\n- Review diffs before committing\n\n## Common Pitfalls to Avoid\n\n- Not checking errors\n- Ignoring race conditions\n- Creating goroutine leaks\n- Not using defer for cleanup\n- Modifying maps concurrently\n- Not understanding nil interfaces vs nil pointers\n- Forgetting to close resources (files, connections)\n- Using global variables unnecessarily\n- Overusing unconstrained types (e.g., `any`); prefer specific types or generic type parameters with constraints. If an unconstrained type is required, use `any` rather than `interface{}`\n- Not considering the zero value of types\n",{"name":5,"description":7},"main","45728854e223fd51b203724ca0e5be9c8f93a5a4",".cratis\u002Fai\u002Fskills\u002Fgithub-copilot-go","https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go","https:\u002F\u002Fwww.cratis.io\u002Ffundamentals\u002Fgo\u002F","https:\u002F\u002Fgithub.com\u002FCratis","https:\u002F\u002Fwww.cratis.io","Open-source (MIT) event sourcing and CQRS for .NET and beyond: Chronicle, Arc, Components and Screenplay.","2026-11-14 15:52:19",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add Cratis\u002FFundamentals.Go --skill github-copilot-go",{"tool":39,"command":40},"bunx","bunx skills add Cratis\u002FFundamentals.Go --skill github-copilot-go",{"tool":42,"command":43},"pnpm","pnpm dlx skills add Cratis\u002FFundamentals.Go --skill github-copilot-go","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fgithub-copilot-go\u002FSKILL.md",true,[47,51],{"path":48,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":50,"sourceHtmlUrl":15},"LICENSE","许可证",1059,{"path":52,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":55,"sourceHtmlUrl":56},"UPSTREAM.md","REFERENCE","参考文档",1903,"https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fgithub-copilot-go\u002FUPSTREAM.md",[58,66,74,82,91,98],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":62,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M7DNCY3BCGY3MC5BFJ9S59BF","spf13-go","Review Go library APIs, package boundaries, tests, iterators and standard-library choices. Load for broad design or idiom reviews after the repository-owned Go skills.","https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fspf13-go\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fspf13-go\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":70,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M7DNCSQQH7GQ03ZETFX9XHAS","samber-golang-error-handling","Review Go error creation, wrapping, inspection and logging boundaries. Load when changing caller-visible failures after go-errors-and-context.","https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fsamber-golang-error-handling\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fsamber-golang-error-handling\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":78,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":19},"01M7DNCM4ZC15SSDA5FAAHN5S0","samber-golang-context","Design Go context propagation, cancellation, deadlines and request metadata. Load for operation-lifetime changes or context-related leaks after go-errors-and-context.","https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fsamber-golang-context\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fsamber-golang-context\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":86,"licenseFileUrl":87,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7DNCGNSMHK640AK1R3J0CPD","jetbrains-go-modern-guidelines","Choose version-compatible modern Go syntax and standard-library APIs. Load when modernizing touched Go code after reading go.mod and build constraints.","Apache-2.0","https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fjetbrains-go-modern-guidelines\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fjetbrains-go-modern-guidelines\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":19},"01M7DNCBYSD6FPAPWM6PPSJR96","go-testing","Write and review Go unit, contract, transport, race, fuzz, and deterministic concurrency tests. Use for new behavior, bug fixes, flaky tests, and public API parity evidence.","https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fgo-testing\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":19},"01M7DNC7ES2RD6WGKC94KMMXTD","go-release-modules","Review Go module dependencies, minimum versions, compatibility, semantic labels, release-action tags, and proxy discoverability. Use for release preparation, retractions, and major-version migration planning.","https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fgo-release-modules\u002FSKILL.md",[],[]]