[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6FG1NJQHNT0FCVC7PANWSYX":3,"skill-same:01M6FG1NJQHNT0FCVC7PANWSYX":53},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":22,"publishedAt":26,"linkOnly":27,"markdownContent":28,"markdownBody":28,"frontMatter":29,"refName":30,"commitSha":31,"skillDirectory":32,"forksCount":33,"repositoryHtmlUrl":34,"repositoryHomepageUrl":35,"ownerHtmlUrl":36,"ownerBlogUrl":6,"ownerDescription":37,"updatedAt":38,"install":39,"resources":52},"01M6FG1NJQHNT0FCVC7PANWSYX","golang-agent-skill",null,"ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fsaisudhir14\u002Fgolang-agent-skill\u002Fgolang-agent-skill\u002FSKILL.md",[17],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[23,24,25],"golang","agent skill","golang agent skill","2026-11-10 10:12:30",false,"# Go Best Practices\n\nBattle-tested patterns from Google, Uber, and the Go team. These are practices proven in large-scale production systems, updated for modern Go (1.25).\n\n## Core Principles\n\nReadable code prioritizes these attributes in order:\n\n1. **Clarity**: purpose and rationale are obvious to the reader\n2. **Simplicity**: accomplishes the goal in the simplest way\n3. **Concision**: high signal to noise ratio\n4. **Maintainability**: easy to modify correctly\n5. **Consistency**: matches surrounding codebase\n\n---\n\n## Error Handling\n\n### Return Errors, Do Not Panic\n\nProduction code must avoid panics. Return errors and let callers decide how to handle them.\n\n```go\n\u002F\u002F Wrong\nfunc run(args []string) {\n    if len(args) == 0 {\n        panic(\"an argument is required\")\n    }\n}\n\n\u002F\u002F Correct\nfunc run(args []string) error {\n    if len(args) == 0 {\n        return errors.New(\"an argument is required\")\n    }\n    return nil\n}\n\nfunc main() {\n    if err := run(os.Args[1:]); err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n}\n```\n\n### Error Wrapping\n\nUse `%w` when callers need to inspect the underlying error with `errors.Is` or `errors.As`. Use `%v` when you want to hide implementation details or at system boundaries.\n\n```go\n\u002F\u002F Preserve error chain for programmatic inspection\nif err != nil {\n    return fmt.Errorf(\"load config: %w\", err)\n}\n\n\u002F\u002F Hide internal details at API boundaries\nif err != nil {\n    return fmt.Errorf(\"database unavailable: %v\", err)\n}\n```\n\nKeep context succinct. Avoid phrases like \"failed to\" that pile up as errors propagate.\n\n```go\n\u002F\u002F Wrong: produces \"failed to x: failed to y: failed to create store: the error\"\nreturn fmt.Errorf(\"failed to create new store: %w\", err)\n\n\u002F\u002F Correct: produces \"x: y: new store: the error\"\nreturn fmt.Errorf(\"new store: %w\", err)\n```\n\n### Joining Multiple Errors (Go 1.20+)\n\nUse `errors.Join` when multiple operations can fail independently.\n\n```go\nfunc validateUser(u User) error {\n    var errs []error\n    if u.Name == \"\" {\n        errs = append(errs, errors.New(\"name required\"))\n    }\n    if u.Email == \"\" {\n        errs = append(errs, errors.New(\"email required\"))\n    }\n    return errors.Join(errs...)\n}\n\n\u002F\u002F Checking joined errors\nif err := validateUser(u); err != nil {\n    if errors.Is(err, ErrNameRequired) {\n        \u002F\u002F handles even when joined with other errors\n    }\n}\n```\n\n### Error Types\n\nChoose based on caller needs:\n\n| Caller needs to match? | Message type | Approach |\n|------------------------|--------------|----------|\n| No | Static | `errors.New(\"something bad\")` |\n| No | Dynamic | `fmt.Errorf(\"file %q not found\", file)` |\n| Yes | Static | Exported `var ErrNotFound = errors.New(\"not found\")` |\n| Yes | Dynamic | Custom error type with `Error()` method |\n\n### Sentinel Errors and errors.Is\n\nDefine sentinel errors for conditions callers need to check.\n\n```go\nvar (\n    ErrNotFound    = errors.New(\"not found\")\n    ErrInvalidUser = errors.New(\"invalid user\")\n)\n\n\u002F\u002F Checking wrapped errors\nif errors.Is(err, ErrNotFound) {\n    \u002F\u002F handles ErrNotFound even when wrapped\n}\n\n\u002F\u002F Custom error types use errors.As\nvar pathErr *os.PathError\nif errors.As(err, &pathErr) {\n    fmt.Println(\"failed path:\", pathErr.Path)\n}\n```\n\n### Error Naming\n\nExported error variables use `Err` prefix. Custom error types use `Error` suffix.\n\n```go\nvar (\n    ErrNotFound    = errors.New(\"not found\")\n    ErrInvalidUser = errors.New(\"invalid user\")\n)\n\ntype NotFoundError struct {\n    Resource string\n}\n\nfunc (e *NotFoundError) Error() string {\n    return fmt.Sprintf(\"%s not found\", e.Resource)\n}\n```\n\n### Handle Errors Once\n\nDo not log an error and also return it. The caller will likely log it again.\n\n```go\n\u002F\u002F Wrong: logs and returns, causing duplicate logs\nif err != nil {\n    log.Printf(\"could not get user %q: %v\", id, err)\n    return err\n}\n\n\u002F\u002F Correct: wrap and return, let caller decide\nif err != nil {\n    return fmt.Errorf(\"get user %q: %w\", id, err)\n}\n\n\u002F\u002F Also correct: log and degrade gracefully without returning error\nif err := emitMetrics(); err != nil {\n    log.Printf(\"could not emit metrics: %v\", err)\n}\n```\n\n### Error Strings\n\nDo not capitalize error strings or end with punctuation. They often appear mid-sentence in logs.\n\n```go\n\u002F\u002F Wrong\nfmt.Errorf(\"Something bad happened.\")\n\n\u002F\u002F Correct\nfmt.Errorf(\"something bad happened\")\n```\n\n### Indent Error Flow\n\nKeep the happy path at minimal indentation. Handle errors first.\n\n```go\n\u002F\u002F Wrong\nif err != nil {\n    \u002F\u002F error handling\n} else {\n    \u002F\u002F normal code\n}\n\n\u002F\u002F Correct\nif err != nil {\n    return err\n}\n\u002F\u002F normal code continues\n```\n\n---\n\n## Concurrency\n\n### Channel Size\n\nChannels should have size zero (unbuffered) or one. Any other size requires justification about what prevents filling under load.\n\n```go\n\u002F\u002F Wrong: arbitrary buffer\nc := make(chan int, 64)\n\n\u002F\u002F Correct\nc := make(chan int)    \u002F\u002F unbuffered: synchronous handoff\nc := make(chan int, 1) \u002F\u002F buffered: allows one pending send\n```\n\n### Goroutine Lifetimes\n\nDocument when and how goroutines exit. Goroutines blocked on channels will not be garbage collected even if the channel is unreachable.\n\n```go\n\u002F\u002F Document exit conditions\nfunc (w *Worker) Run(ctx context.Context) error {\n    for {\n        select {\n        case \u003C-ctx.Done():\n            return ctx.Err()\n        case job := \u003C-w.jobs:\n            w.process(job)\n        }\n    }\n}\n```\n\n### Use errgroup for Concurrent Operations\n\nPrefer `errgroup.Group` over manual `sync.WaitGroup` for error-returning goroutines.\n\n```go\nimport \"golang.org\u002Fx\u002Fsync\u002Ferrgroup\"\n\nfunc processItems(ctx context.Context, items []Item) error {\n    g, ctx := errgroup.WithContext(ctx)\n    \n    for _, item := range items {\n        g.Go(func() error {\n            return process(ctx, item)\n        })\n    }\n    \n    return g.Wait() \u002F\u002F returns first error, cancels others via ctx\n}\n\n\u002F\u002F With concurrency limit\nfunc processItemsLimited(ctx context.Context, items []Item) error {\n    g, ctx := errgroup.WithContext(ctx)\n    g.SetLimit(10) \u002F\u002F max 10 concurrent goroutines\n    \n    for _, item := range items {\n        g.Go(func() error {\n            return process(ctx, item)\n        })\n    }\n    \n    return g.Wait()\n}\n```\n\n### Prefer Synchronous Functions\n\nSynchronous functions are easier to reason about and test. Let callers add concurrency when needed.\n\n```go\n\u002F\u002F Wrong: forces concurrency on caller\nfunc Fetch(url string) \u003C-chan Result\n\n\u002F\u002F Correct: caller can wrap in goroutine if needed\nfunc Fetch(url string) (Result, error)\n```\n\n### Zero Value Mutexes\n\nThe zero value of `sync.Mutex` is valid. Do not use pointers to mutexes or embed them in exported structs.\n\n```go\n\u002F\u002F Wrong\nmu := new(sync.Mutex)\n\n\u002F\u002F Wrong: exposes Lock\u002FUnlock in API\ntype SMap struct {\n    sync.Mutex\n    data map[string]string\n}\n\n\u002F\u002F Correct\ntype SMap struct {\n    mu   sync.Mutex\n    data map[string]string\n}\n```\n\n### Atomic Operations (Go 1.19+)\n\nUse the standard library's typed atomics. External packages are no longer necessary.\n\n```go\nimport \"sync\u002Fatomic\"\n\ntype Counter struct {\n    value atomic.Int64\n}\n\nfunc (c *Counter) Inc() {\n    c.value.Add(1)\n}\n\nfunc (c *Counter) Value() int64 {\n    return c.value.Load()\n}\n\n\u002F\u002F Also available: atomic.Bool, atomic.Pointer[T], atomic.Uint32, etc.\n```\n\n### sync.Map Performance (Go 1.24+)\n\nThe `sync.Map` implementation was significantly improved in Go 1.24. Modifications of disjoint sets of keys are much less likely to contend on larger maps, and there is no longer any ramp-up time required to achieve low-contention loads.\n\n---\n\n## Naming\n\n### MixedCaps Always\n\nGo uses MixedCaps, never underscores. This applies even when it breaks other language conventions.\n\n```go\n\u002F\u002F Wrong\nMAX_LENGTH, max_length, HTTP_Server\n\n\u002F\u002F Correct\nMaxLength, maxLength, HTTPServer\n```\n\n### Initialisms\n\nInitialisms maintain consistent case: URL not Url, ID not Id, HTTP not Http.\n\n```go\n\u002F\u002F Wrong\nxmlHttpRequest, serverId, apiUrl\n\n\u002F\u002F Correct\nxmlHTTPRequest, serverID, apiURL\n```\n\n### Short Variable Names\n\nVariables should be short, especially with limited scope. The further from declaration a name is used, the more descriptive it needs to be.\n\n```go\n\u002F\u002F Good for local scope\nfor i, v := range items { }\nr := bufio.NewReader(f)\n\n\u002F\u002F Global or struct fields need more context\nvar DefaultTimeout = 30 * time.Second\n```\n\n### Receiver Names\n\nUse one or two letter abbreviations of the type. Be consistent across methods. Do not use generic names like `this`, `self`, or `me`.\n\n```go\n\u002F\u002F Wrong\nfunc (this *Client) Get() {}\nfunc (c *Client) Get() {}\nfunc (cl *Client) Post() {} \u002F\u002F inconsistent\n\n\u002F\u002F Correct\nfunc (c *Client) Get() {}\nfunc (c *Client) Post() {}\n```\n\n### Pointer vs Value Receivers\n\n| Use pointer receiver when | Use value receiver when |\n|---------------------------|-------------------------|\n| Method modifies the receiver | Struct is small and immutable |\n| Struct is large (avoid copying) | Method doesn't modify state |\n| Consistency with other methods | Receiver is a map, func, or chan |\n| Struct contains sync.Mutex | Basic types (int, string, etc.) |\n\n```go\n\u002F\u002F Pointer: modifies state\nfunc (s *Server) Shutdown() error {\n    s.running = false\n    return s.listener.Close()\n}\n\n\u002F\u002F Value: small, read-only\nfunc (p Point) Distance(q Point) float64 {\n    return math.Hypot(p.X-q.X, p.Y-q.Y)\n}\n```\n\n### Package Names\n\nPackage names are lowercase, single words. Avoid util, common, misc, api, types. The package name becomes part of the identifier at call sites.\n\n```go\n\u002F\u002F Wrong\npackage chubby\ntype ChubbyFile struct{}  \u002F\u002F chubby.ChubbyFile is redundant\n\n\u002F\u002F Correct\npackage chubby\ntype File struct{}  \u002F\u002F chubby.File reads well\n```\n\n### Avoid Repetition in Names\n\nDo not repeat package or receiver names in function names.\n\n```go\n\u002F\u002F Wrong\npackage http\nfunc HTTPServe() {}  \u002F\u002F http.HTTPServe is redundant\n\nfunc (c *Config) WriteConfigTo(w io.Writer) {}  \u002F\u002F Config repeated\n\n\u002F\u002F Correct\npackage http\nfunc Serve() {}  \u002F\u002F http.Serve\n\nfunc (c *Config) WriteTo(w io.Writer) {}\n```\n\n---\n\n## Imports\n\n### Grouping\n\nOrganize imports in three groups separated by blank lines: standard library, external packages, internal packages.\n\n```go\nimport (\n    \"context\"\n    \"fmt\"\n    \"os\"\n\n    \"github.com\u002Fgoogle\u002Fuuid\"\n    \"golang.org\u002Fx\u002Fsync\u002Ferrgroup\"\n\n    \"yourcompany\u002Finternal\u002Fconfig\"\n    \"yourcompany\u002Finternal\u002Fmetrics\"\n)\n```\n\n### Avoid Renaming\n\nRename imports only to avoid collisions. Prefer renaming the most local import.\n\n### Avoid Import Dot\n\nThe dot import (`import . \"pkg\"`) makes code harder to read. Use only in test files with circular dependencies.\n\n### Blank Imports\n\nImport for side effects (`import _ \"pkg\"`) only in main packages or tests.\n\n---\n\n## Module Management\n\n### Tool Directives (Go 1.24+)\n\nGo modules can now track executable dependencies using tool directives in go.mod. This removes the need for the previous workaround of adding tools as blank imports to a file conventionally named \"tools.go\".\n\n```go\n\u002F\u002F go.mod\nmodule example.com\u002Fmyproject\n\ngo 1.24\n\ntool (\n    golang.org\u002Fx\u002Ftools\u002Fcmd\u002Fstringer\n    github.com\u002Fgolangci\u002Fgolangci-lint\u002Fcmd\u002Fgolangci-lint\n)\n```\n\n```bash\n# Add a tool dependency\ngo get -tool golang.org\u002Fx\u002Ftools\u002Fcmd\u002Fstringer\n\n# Run a tool\ngo tool stringer -type=Status\n\n# Update all tools\ngo get tool\n\n# Install all tools to GOBIN\ngo install tool\n```\n\n---\n\n## Structs\n\n### Use Field Names in Initialization\n\nAlways use field names. Positional arguments break when fields are added.\n\n```go\n\u002F\u002F Wrong: breaks if fields change\nk := User{\"John\", \"john@example.com\", true}\n\n\u002F\u002F Correct\nk := User{\n    Name:   \"John\",\n    Email:  \"john@example.com\",\n    Active: true,\n}\n```\n\n### Omit Zero Value Fields\n\nDo not initialize fields to their zero values.\n\n```go\n\u002F\u002F Wrong\nuser := User{\n    Name:   \"John\",\n    Active: false,  \u002F\u002F false is zero value\n    Count:  0,      \u002F\u002F 0 is zero value\n}\n\n\u002F\u002F Correct\nuser := User{\n    Name: \"John\",\n}\n```\n\n### Embedding\n\nDo not embed types in public structs. Embedding exposes methods and fields to the public API unintentionally.\n\n```go\n\u002F\u002F Wrong: Lock and Unlock become part of SMap's API\ntype SMap struct {\n    sync.Mutex\n    data map[string]string\n}\n\n\u002F\u002F Correct\ntype SMap struct {\n    mu   sync.Mutex\n    data map[string]string\n}\n```\n\n### Use var for Zero Value Structs\n\n```go\n\u002F\u002F Correct\nvar user User\n\n\u002F\u002F Also acceptable\nuser := User{}\n```\n\n---\n\n## Slices and Maps\n\n### Nil Slice Declaration\n\nPrefer nil slices over empty slices. They are functionally equivalent but nil is the preferred style.\n\n```go\n\u002F\u002F Preferred\nvar t []string\n\n\u002F\u002F Use only when JSON must encode as [] instead of null\nt := []string{}\n```\n\n### Copy at Boundaries\n\nSlices and maps hold references. Copy them when storing or returning to prevent mutation.\n\n```go\n\u002F\u002F Wrong: caller can modify internal state\nfunc (d *Driver) SetTrips(trips []Trip) {\n    d.trips = trips\n}\n\n\u002F\u002F Correct\nfunc (d *Driver) SetTrips(trips []Trip) {\n    d.trips = make([]Trip, len(trips))\n    copy(d.trips, trips)\n}\n\n\u002F\u002F For maps\nfunc (d *Driver) SetMetadata(m map[string]string) {\n    d.metadata = maps.Clone(m)\n}\n```\n\n### Specify Capacity\n\nPreallocate when size is known. This reduces allocations.\n\n```go\n\u002F\u002F Wrong\nvar result []Item\nfor _, v := range input {\n    result = append(result, transform(v))\n}\n\n\u002F\u002F Correct\nresult := make([]Item, 0, len(input))\nfor _, v := range input {\n    result = append(result, transform(v))\n}\n```\n\n### Use slices and maps Packages\n\nPrefer standard library functions for common operations.\n\n```go\nimport (\n    \"cmp\"\n    \"maps\"\n    \"slices\"\n)\n\n\u002F\u002F Sorting\nslices.Sort(numbers)\nslices.SortFunc(users, func(a, b User) int {\n    return cmp.Compare(a.Name, b.Name)\n})\n\n\u002F\u002F Searching\nidx, found := slices.BinarySearch(sorted, target)\n\n\u002F\u002F Cloning\ncopy := slices.Clone(original)\nmapCopy := maps.Clone(original)\n\n\u002F\u002F Comparison\nif slices.Equal(a, b) { }\nif maps.Equal(m1, m2) { }\n```\n\n---\n\n## Generics (Go 1.18+)\n\n### When to Use Generics\n\nUse generics when you find yourself writing the same code for different types.\n\n```go\n\u002F\u002F Generic helper functions\nfunc Filter[T any](slice []T, predicate func(T) bool) []T {\n    result := make([]T, 0, len(slice))\n    for _, v := range slice {\n        if predicate(v) {\n            result = append(result, v)\n        }\n    }\n    return result\n}\n\nfunc Map[T, U any](slice []T, transform func(T) U) []U {\n    result := make([]U, len(slice))\n    for i, v := range slice {\n        result[i] = transform(v)\n    }\n    return result\n}\n\n\u002F\u002F Usage\nadults := Filter(users, func(u User) bool { return u.Age >= 18 })\nnames := Map(users, func(u User) string { return u.Name })\n```\n\n### Type Constraints\n\nUse constraints for type safety.\n\n```go\nimport \"cmp\"\n\n\u002F\u002F cmp.Ordered covers all comparable types\nfunc Max[T cmp.Ordered](a, b T) T {\n    if a > b {\n        return a\n    }\n    return b\n}\n\n\u002F\u002F Custom constraints\ntype Number interface {\n    ~int | ~int64 | ~float64\n}\n\nfunc Sum[T Number](values []T) T {\n    var total T\n    for _, v := range values {\n        total += v\n    }\n    return total\n}\n```\n\n### Generic Type Aliases (Go 1.24+)\n\nType aliases can now be parameterized like defined types.\n\n```go\n\u002F\u002F Generic type alias\ntype Set[T comparable] = map[T]struct{}\n\n\u002F\u002F Usage\nvar s Set[string]\ns = make(Set[string])\ns[\"hello\"] = struct{}{}\n\n\u002F\u002F With constraints\ntype OrderedSlice[T cmp.Ordered] = []T\n```\n\n### Avoid Over-Generalization\n\nDo not use generics when a concrete type or interface suffices.\n\n```go\n\u002F\u002F Wrong: unnecessary generic\nfunc PrintAll[T fmt.Stringer](items []T) {\n    for _, item := range items {\n        fmt.Println(item.String())\n    }\n}\n\n\u002F\u002F Correct: interface is sufficient\nfunc PrintAll(items []fmt.Stringer) {\n    for _, item := range items {\n        fmt.Println(item.String())\n    }\n}\n```\n\n---\n\n## Iterators (Go 1.23+)\n\n### Range Over Functions\n\nGo 1.23 introduced range-over-func, allowing custom iterators.\n\n```go\n\u002F\u002F Iterator function signature\ntype Seq[V any] func(yield func(V) bool)\ntype Seq2[K, V any] func(yield func(K, V) bool)\n\n\u002F\u002F Custom iterator\nfunc Backward[T any](s []T) func(yield func(int, T) bool) {\n    return func(yield func(int, T) bool) {\n        for i := len(s) - 1; i >= 0; i-- {\n            if !yield(i, s[i]) {\n                return\n            }\n        }\n    }\n}\n\n\u002F\u002F Usage\nfor i, v := range Backward(items) {\n    fmt.Println(i, v)\n}\n```\n\n### String and Bytes Iterators (Go 1.24+)\n\nNew iterator functions for efficient string and byte processing.\n\n```go\nimport \"strings\"\n\n\u002F\u002F Iterate over lines (includes newline characters)\ntext := \"line1\\nline2\\nline3\"\nfor line := range strings.Lines(text) {\n    fmt.Print(line)\n}\n\n\u002F\u002F Split by delimiter (iterator, no slice allocation)\ncsvData := \"apple,banana,cherry\"\nfor value := range strings.SplitSeq(csvData, \",\") {\n    fmt.Println(value)\n}\n\n\u002F\u002F Split after delimiter\nfor part := range strings.SplitAfterSeq(csvData, \",\") {\n    fmt.Println(part) \u002F\u002F \"apple,\" \"banana,\" \"cherry\"\n}\n\n\u002F\u002F Equivalent functions exist in bytes package\n```\n\n---\n\n## Structured Logging (Go 1.21+)\n\n### Use slog for New Code\n\nThe standard library now includes structured logging.\n\n```go\nimport \"log\u002Fslog\"\n\n\u002F\u002F Basic usage\nslog.Info(\"user created\", \"id\", userID, \"email\", email)\nslog.Error(\"request failed\", \"err\", err, \"method\", r.Method)\n\n\u002F\u002F With context\nlogger := slog.With(\"service\", \"auth\", \"version\", \"1.0\")\nlogger.Info(\"starting\")\n\n\u002F\u002F JSON output for production\nhandler := slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{\n    Level: slog.LevelInfo,\n})\nslog.SetDefault(slog.New(handler))\n```\n\n### slog.DiscardHandler (Go 1.24+)\n\nUse the built-in discard handler for suppressing logs in tests.\n\n```go\n\u002F\u002F Before Go 1.24\nlog := slog.New(slog.NewJSONHandler(io.Discard, nil))\n\n\u002F\u002F Go 1.24+\nlog := slog.New(slog.DiscardHandler)\n```\n\n### Structured Logging Best Practices\n\n```go\n\u002F\u002F Use consistent key names\nslog.Info(\"request completed\",\n    \"method\", r.Method,\n    \"path\", r.URL.Path,\n    \"status\", statusCode,\n    \"duration_ms\", duration.Milliseconds(),\n)\n\n\u002F\u002F Group related fields\nslog.Info(\"user action\",\n    slog.Group(\"user\",\n        \"id\", user.ID,\n        \"role\", user.Role,\n    ),\n    slog.Group(\"request\",\n        \"method\", r.Method,\n        \"path\", r.URL.Path,\n    ),\n)\n```\n\n---\n\n## Performance\n\n### Prefer strconv Over fmt\n\nstrconv is faster for primitive conversions.\n\n```go\n\u002F\u002F Slower\ns := fmt.Sprintf(\"%d\", n)\n\n\u002F\u002F Faster\ns := strconv.Itoa(n)\n```\n\n### Avoid Repeated String to Byte Conversions\n\n```go\n\u002F\u002F Wrong: converts on every iteration\nfor i := 0; i \u003C n; i++ {\n    w.Write([]byte(\"hello\"))\n}\n\n\u002F\u002F Correct\ndata := []byte(\"hello\")\nfor i := 0; i \u003C n; i++ {\n    w.Write(data)\n}\n```\n\n### Specify Map Capacity\n\n```go\n\u002F\u002F Wrong\nm := make(map[string]int)\n\n\u002F\u002F Correct when size is known\nm := make(map[string]int, len(items))\n```\n\n### Use strings.Builder for Concatenation\n\n```go\n\u002F\u002F Wrong: creates many allocations\nvar s string\nfor _, part := range parts {\n    s += part\n}\n\n\u002F\u002F Correct\nvar b strings.Builder\nb.Grow(totalLen) \u002F\u002F optional: preallocate\nfor _, part := range parts {\n    b.WriteString(part)\n}\ns := b.String()\n```\n\n---\n\n## Testing\n\n### Table Driven Tests with Parallel Execution\n\nUse table driven tests to avoid code duplication. Run subtests in parallel when safe.\n\n```go\nfunc TestSplit(t *testing.T) {\n    tests := []struct {\n        name  string\n        input string\n        sep   string\n        want  []string\n    }{\n        {\n            name:  \"simple\",\n            input: \"a\u002Fb\u002Fc\",\n            sep:   \"\u002F\",\n            want:  []string{\"a\", \"b\", \"c\"},\n        },\n        {\n            name:  \"empty\",\n            input: \"\",\n            sep:   \"\u002F\",\n            want:  []string{\"\"},\n        },\n    }\n\n    for _, tt := range tests {\n        t.Run(tt.name, func(t *testing.T) {\n            t.Parallel() \u002F\u002F run subtests concurrently\n            \n            got := strings.Split(tt.input, tt.sep)\n            if diff := cmp.Diff(tt.want, got); diff != \"\" {\n                t.Errorf(\"Split() mismatch (-want +got):\\n%s\", diff)\n            }\n        })\n    }\n}\n```\n\n### T.Context and T.Chdir (Go 1.24+)\n\nNew helper methods for test context and working directory.\n\n```go\nfunc TestWithContext(t *testing.T) {\n    \u002F\u002F T.Context returns a context canceled after test completes\n    \u002F\u002F but before cleanup functions run\n    ctx := t.Context()\n    \n    result, err := doWork(ctx)\n    if err != nil {\n        t.Fatal(err)\n    }\n    \u002F\u002F ...\n}\n\nfunc TestWithChdir(t *testing.T) {\n    \u002F\u002F T.Chdir changes working directory for duration of test\n    \u002F\u002F and automatically restores it after\n    t.Chdir(\"testdata\")\n    \n    \u002F\u002F Now in testdata directory\n    data, err := os.ReadFile(\"input.txt\")\n    \u002F\u002F ...\n}\n```\n\n### Benchmark with b.Loop (Go 1.24+)\n\nUse `b.Loop()` for cleaner, more accurate benchmarks.\n\n```go\n\u002F\u002F Old way - error prone\nfunc BenchmarkOld(b *testing.B) {\n    input := setupInput() \u002F\u002F counted in benchmark time!\n    b.ResetTimer()        \u002F\u002F easy to forget\n    for i := 0; i \u003C b.N; i++ {\n        process(input)    \u002F\u002F compiler might optimize away\n    }\n}\n\n\u002F\u002F Go 1.24+ - preferred\nfunc BenchmarkNew(b *testing.B) {\n    input := setupInput() \u002F\u002F setup runs once, excluded from timing\n    for b.Loop() {\n        process(input)    \u002F\u002F compiler cannot optimize away\n    }\n}\n```\n\nBenefits of `b.Loop()`:\n- Setup code runs exactly once per `-count`, automatically excluded from timing\n- No need to call `b.ResetTimer()`\n- Function call parameters and results are kept alive, preventing compiler optimization\n\n### Testing Concurrent Code with synctest (Go 1.25+)\n\nThe `testing\u002Fsynctest` package provides deterministic testing for concurrent code using synthetic time.\n\n```go\nimport \"testing\u002Fsynctest\"\n\nfunc TestTimeout(t *testing.T) {\n    synctest.Test(t, func(t *testing.T) {\n        ctx, cancel := context.WithTimeout(t.Context(), 5*time.Second)\n        defer cancel()\n        \n        \u002F\u002F Inside the \"bubble\", time is synthetic\n        \u002F\u002F This sleep completes instantly in real time\n        time.Sleep(4 * time.Second)\n        \n        \u002F\u002F Context should not be expired yet\n        if err := ctx.Err(); err != nil {\n            t.Fatalf(\"unexpected timeout: %v\", err)\n        }\n        \n        \u002F\u002F Advance past the timeout\n        time.Sleep(2 * time.Second)\n        \n        \u002F\u002F Now it should be expired\n        if ctx.Err() != context.DeadlineExceeded {\n            t.Fatal(\"expected deadline exceeded\")\n        }\n    })\n}\n```\n\nKey concepts:\n- `synctest.Test` creates an isolated \"bubble\" with synthetic time\n- Time only advances when all goroutines in the bubble are blocked\n- Initial time is midnight UTC 2000-01-01\n- `synctest.Wait()` waits for all goroutines to be durably blocked\n\n```go\nfunc TestConcurrentCounter(t *testing.T) {\n    synctest.Test(t, func(t *testing.T) {\n        var counter atomic.Int64\n        var wg sync.WaitGroup\n        \n        \u002F\u002F Start concurrent workers\n        for i := 0; i \u003C 10; i++ {\n            wg.Add(1)\n            go func() {\n                defer wg.Done()\n                counter.Add(1)\n            }()\n        }\n        \n        \u002F\u002F Wait for all goroutines to complete\n        wg.Wait()\n        \n        \u002F\u002F Counter is now deterministically 10\n        if got := counter.Load(); got != 10 {\n            t.Errorf(\"got %d, want 10\", got)\n        }\n    })\n}\n\n\u002F\u002F Example with time-based operations\nfunc TestPeriodicTask(t *testing.T) {\n    synctest.Test(t, func(t *testing.T) {\n        var count atomic.Int64\n        ctx, cancel := context.WithCancel(t.Context())\n        \n        \u002F\u002F Start a periodic task\n        go func() {\n            ticker := time.NewTicker(100 * time.Millisecond)\n            defer ticker.Stop()\n            for {\n                select {\n                case \u003C-ctx.Done():\n                    return\n                case \u003C-ticker.C:\n                    count.Add(1)\n                }\n            }\n        }()\n        \n        \u002F\u002F Advance synthetic time by 350ms\n        time.Sleep(350 * time.Millisecond)\n        synctest.Wait() \u002F\u002F wait for goroutine to process\n        \n        cancel()\n        synctest.Wait() \u002F\u002F wait for goroutine to exit\n        \n        \u002F\u002F Should have ticked 3 times (at 100ms, 200ms, 300ms)\n        if got := count.Load(); got != 3 {\n            t.Errorf(\"got %d ticks, want 3\", got)\n        }\n    })\n}\n```\n\n**Important restrictions in synctest bubbles:**\n- Do not call `t.Run()`, `t.Parallel()`, or `t.Deadline()`\n- Channels created outside the bubble behave differently\n- External I\u002FO operations are not durably blocking\n\n### Use go-cmp for Comparisons\n\nPrefer `github.com\u002Fgoogle\u002Fgo-cmp\u002Fcmp` over `reflect.DeepEqual`.\n\n```go\nimport \"github.com\u002Fgoogle\u002Fgo-cmp\u002Fcmp\"\n\n\u002F\u002F Clear diff output on failure\nif diff := cmp.Diff(want, got); diff != \"\" {\n    t.Errorf(\"mismatch (-want +got):\\n%s\", diff)\n}\n\n\u002F\u002F With options for custom comparison\nif diff := cmp.Diff(want, got, cmpopts.IgnoreUnexported(User{})); diff != \"\" {\n    t.Errorf(\"mismatch (-want +got):\\n%s\", diff)\n}\n```\n\n### Useful Test Failures\n\nInclude: what was wrong, inputs, actual result, expected result.\n\n```go\n\u002F\u002F Wrong\nif got != want {\n    t.Error(\"wrong result\")\n}\n\n\u002F\u002F Correct\nif got != want {\n    t.Errorf(\"Foo(%q) = %d; want %d\", input, got, want)\n}\n```\n\n### Use t.Fatal for Setup Failures\n\n```go\nf, err := os.CreateTemp(\"\", \"test\")\nif err != nil {\n    t.Fatal(\"failed to set up test\")\n}\n```\n\n### Interfaces Belong to Consumers\n\nDefine interfaces in the package that uses them, not the package that implements them.\n\n```go\n\u002F\u002F Wrong: defining interface in producer\npackage producer\ntype Thinger interface { Thing() bool }\nfunc NewThinger() Thinger { return &thinger{} }\n\n\u002F\u002F Correct: producer returns concrete type\npackage producer\ntype Thinger struct{}\nfunc (t *Thinger) Thing() bool { return true }\nfunc NewThinger() *Thinger { return &Thinger{} }\n\n\u002F\u002F Consumer defines interface it needs\npackage consumer\ntype Thinger interface { Thing() bool }\nfunc Process(t Thinger) { }\n```\n\n---\n\n## Resource Management\n\n### runtime.AddCleanup (Go 1.24+)\n\nPrefer `runtime.AddCleanup` over `runtime.SetFinalizer` for cleanup operations.\n\n```go\nimport \"runtime\"\n\ntype Resource struct {\n    handle uintptr\n}\n\nfunc NewResource() *Resource {\n    r := &Resource{handle: allocHandle()}\n    \n    \u002F\u002F AddCleanup is more flexible than SetFinalizer:\n    \u002F\u002F - Multiple cleanups can be attached to one object\n    \u002F\u002F - Works with interior pointers\n    \u002F\u002F - Doesn't cause leaks with cycles\n    \u002F\u002F - Doesn't delay freeing the object\n    runtime.AddCleanup(r, func(handle uintptr) {\n        freeHandle(handle)\n    }, r.handle)\n    \n    return r\n}\n```\n\nKey advantages over `SetFinalizer`:\n- Multiple cleanups per object\n- Works with interior pointers\n- No cycle-related leaks\n- Object freed promptly (single GC cycle)\n\n### Weak Pointers (Go 1.24+)\n\nThe `weak` package provides weak references that don't prevent garbage collection.\n\n```go\nimport \"weak\"\n\n\u002F\u002F Create a weak pointer from a strong pointer\ntype ExpensiveResource struct {\n    data []byte\n}\n\nfunc NewCache() *Cache {\n    return &Cache{\n        items: make(map[string]weak.Pointer[ExpensiveResource]),\n    }\n}\n\ntype Cache struct {\n    mu    sync.Mutex\n    items map[string]weak.Pointer[ExpensiveResource]\n}\n\nfunc (c *Cache) Get(key string) *ExpensiveResource {\n    c.mu.Lock()\n    defer c.mu.Unlock()\n    \n    if wp, ok := c.items[key]; ok {\n        \u002F\u002F Value returns the original pointer, or nil if collected\n        if r := wp.Value(); r != nil {\n            return r\n        }\n        \u002F\u002F Resource was garbage collected, remove stale entry\n        delete(c.items, key)\n    }\n    return nil\n}\n\nfunc (c *Cache) Set(key string, r *ExpensiveResource) {\n    c.mu.Lock()\n    defer c.mu.Unlock()\n    \u002F\u002F Make creates a weak pointer from a strong pointer\n    c.items[key] = weak.Make(r)\n}\n```\n\nUse cases for weak pointers:\n- Caches that shouldn't prevent garbage collection\n- Canonicalization maps (interning)\n- Observer patterns where observers may be collected\n\n### Secure Directory Access with os.Root (Go 1.24+)\n\nThe `os.Root` type provides safe, scoped file system access that prevents path traversal attacks.\n\n```go\nimport \"os\"\n\nfunc ServeUserFiles(userDir string) http.HandlerFunc {\n    return func(w http.ResponseWriter, r *http.Request) {\n        \u002F\u002F OpenRoot opens a directory as a root for safe access\n        root, err := os.OpenRoot(userDir)\n        if err != nil {\n            http.Error(w, \"directory not found\", http.StatusNotFound)\n            return\n        }\n        defer root.Close()\n        \n        \u002F\u002F Open is safe: paths are resolved relative to root\n        \u002F\u002F Attempts to escape (like \"..\u002Fetc\u002Fpasswd\") are rejected\n        filename := r.URL.Query().Get(\"file\")\n        f, err := root.Open(filename)\n        if err != nil {\n            http.Error(w, \"file not found\", http.StatusNotFound)\n            return\n        }\n        defer f.Close()\n        \n        io.Copy(w, f)\n    }\n}\n\n\u002F\u002F Available methods on os.Root:\n\u002F\u002F - Open(name) - open file for reading\n\u002F\u002F - Create(name) - create or truncate file\n\u002F\u002F - OpenFile(name, flag, perm) - open with flags\n\u002F\u002F - Mkdir(name, perm) - create directory\n\u002F\u002F - Remove(name) - remove file or empty directory\n\u002F\u002F - Stat(name), Lstat(name) - file info\n\u002F\u002F - ReadDir(name) - list directory contents\n```\n\nKey benefits:\n- Prevents path traversal vulnerabilities (\"..\u002F\" attacks)\n- Symlinks cannot escape the root directory\n- Race-condition safe (uses openat2 on Linux)\n- Drop-in replacement for typical file operations\n\n---\n\n## Patterns\n\n### Functional Options\n\nUse functional options for configurable constructors with many optional parameters.\n\n```go\ntype Server struct {\n    addr    string\n    timeout time.Duration\n    logger  *slog.Logger\n}\n\ntype Option func(*Server)\n\nfunc WithTimeout(d time.Duration) Option {\n    return func(s *Server) { s.timeout = d }\n}\n\nfunc WithLogger(l *slog.Logger) Option {\n    return func(s *Server) { s.logger = l }\n}\n\nfunc NewServer(addr string, opts ...Option) *Server {\n    s := &Server{\n        addr:    addr,\n        timeout: 30 * time.Second,\n        logger:  slog.Default(),\n    }\n    for _, opt := range opts {\n        opt(s)\n    }\n    return s\n}\n\n\u002F\u002F Usage\nsrv := NewServer(\"localhost:8080\",\n    WithTimeout(60*time.Second),\n    WithLogger(logger),\n)\n```\n\n### Verify Interface Compliance\n\nUse compile time checks to verify interface implementations.\n\n```go\ntype Handler struct{}\n\nvar _ http.Handler = (*Handler)(nil)\n\nfunc (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {}\n```\n\n### Defer for Cleanup\n\nUse defer to clean up resources. The small overhead is worth the readability and safety.\n\n```go\np.Lock()\ndefer p.Unlock()\n\nif p.count \u003C 10 {\n    return p.count\n}\np.count++\nreturn p.count\n```\n\n### Graceful Shutdown Pattern\n\nProduction servers need graceful shutdown to drain connections.\n\n```go\nfunc main() {\n    srv := &http.Server{Addr: \":8080\", Handler: handler}\n\n    \u002F\u002F Start server in goroutine\n    go func() {\n        if err := srv.ListenAndServe(); err != http.ErrServerClosed {\n            slog.Error(\"server error\", \"err\", err)\n        }\n    }()\n\n    \u002F\u002F Wait for interrupt signal\n    quit := make(chan os.Signal, 1)\n    signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)\n    \u003C-quit\n\n    \u002F\u002F Graceful shutdown with timeout\n    ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)\n    defer cancel()\n    \n    if err := srv.Shutdown(ctx); err != nil {\n        slog.Error(\"shutdown error\", \"err\", err)\n    }\n    slog.Info(\"server stopped\")\n}\n```\n\n### Start Enums at One\n\nZero values should represent invalid or unset state.\n\n```go\ntype Operation int\n\nconst (\n    OperationUnknown Operation = iota \u002F\u002F 0 = invalid\n    OperationAdd                      \u002F\u002F 1\n    OperationSubtract                 \u002F\u002F 2\n)\n```\n\n### Use time Package for Time\n\nDo not use integers for time. Use `time.Time` for instants and `time.Duration` for periods.\n\n```go\n\u002F\u002F Wrong\nfunc poll(delay int) {\n    time.Sleep(time.Duration(delay) * time.Millisecond)\n}\npoll(10) \u002F\u002F is this seconds or milliseconds?\n\n\u002F\u002F Correct\nfunc poll(delay time.Duration) {\n    time.Sleep(delay)\n}\npoll(10 * time.Second)\n```\n\n### Handle Type Assertions\n\nAlways use the two value form to avoid panics.\n\n```go\n\u002F\u002F Wrong: panics on wrong type\nt := i.(string)\n\n\u002F\u002F Correct\nt, ok := i.(string)\nif !ok {\n    \u002F\u002F handle error\n}\n```\n\n### Context as First Parameter\n\nContext should be the first parameter, named ctx. Do not store context in structs.\n\n```go\nfunc (s *Service) Process(ctx context.Context, req *Request) (*Response, error) {\n    \u002F\u002F ...\n}\n```\n\n### Avoid Mutable Globals\n\nUse dependency injection instead of modifying global state.\n\n```go\n\u002F\u002F Wrong\nvar db *sql.DB\n\nfunc init() {\n    db, _ = sql.Open(\"postgres\", os.Getenv(\"DSN\"))\n}\n\n\u002F\u002F Correct\ntype Server struct {\n    db *sql.DB\n}\n\nfunc NewServer(db *sql.DB) *Server {\n    return &Server{db: db}\n}\n```\n\n### Avoid init()\n\nPrefer explicit initialization in main. init() makes code harder to reason about and test.\n\n### Embed Static Files (Go 1.16+)\n\nUse `\u002F\u002Fgo:embed` for static assets.\n\n```go\nimport \"embed\"\n\n\u002F\u002Fgo:embed templates\u002F*\nvar templates embed.FS\n\n\u002F\u002Fgo:embed config.json\nvar configData []byte\n```\n\n### Use Field Tags in Marshaled Structs\n\nExplicit field names protect against accidental contract changes from refactoring.\n\n```go\ntype User struct {\n    Name  string `json:\"name\"`\n    Email string `json:\"email\"`\n}\n```\n\n---\n\n## Container and Runtime Considerations\n\n### Container-Aware GOMAXPROCS (Go 1.25+)\n\nGo 1.25 automatically adjusts GOMAXPROCS based on container CPU limits.\n\n```go\n\u002F\u002F On Linux with cgroups, GOMAXPROCS now considers:\n\u002F\u002F - CPU bandwidth limits (CPU limit in Kubernetes)\n\u002F\u002F - Changes dynamically if limits change\n\n\u002F\u002F The runtime periodically updates GOMAXPROCS if:\n\u002F\u002F - Number of logical CPUs changes\n\u002F\u002F - cgroup CPU bandwidth limit changes\n\n\u002F\u002F Automatic behavior is disabled if you set GOMAXPROCS explicitly:\n\u002F\u002F - Via GOMAXPROCS environment variable\n\u002F\u002F - Via runtime.GOMAXPROCS() call\n```\n\nThis means Go programs in containers should now perform better out-of-the-box without manual GOMAXPROCS tuning.\n\n---\n\n## Common Gotchas\n\n### Loop Variable Capture (Fixed in Go 1.22+)\n\nPrior to Go 1.22, loop variables were reused. This is no longer an issue.\n\n```go\n\u002F\u002F Pre-Go 1.22: All goroutines see last value\nfor _, v := range values {\n    go func() {\n        process(v) \u002F\u002F Wrong: captures loop variable\n    }()\n}\n\n\u002F\u002F Fix for pre-Go 1.22\nfor _, v := range values {\n    v := v \u002F\u002F shadow the loop variable\n    go func() {\n        process(v)\n    }()\n}\n\n\u002F\u002F Go 1.22+: Loop variables are per-iteration (no fix needed)\nfor _, v := range values {\n    go func() {\n        process(v) \u002F\u002F Safe: v is unique per iteration\n    }()\n}\n```\n\n### Defer Argument Evaluation\n\nDefer evaluates arguments immediately, not when deferred function runs.\n\n```go\n\u002F\u002F Wrong: always prints 0\nfor i := 0; i \u003C 5; i++ {\n    defer fmt.Println(i) \u002F\u002F i evaluated when defer is called\n}\n\u002F\u002F Prints: 4 3 2 1 0\n\n\u002F\u002F Gotcha with file handles\nfor _, f := range files {\n    defer f.Close() \u002F\u002F All defer the same f!\n}\n\n\u002F\u002F Fix: capture in closure\nfor _, f := range files {\n    f := f\n    defer f.Close()\n}\n```\n\n### Nil Interface vs Nil Pointer\n\nAn interface containing a nil pointer is not nil.\n\n```go\ntype MyError struct{}\nfunc (e *MyError) Error() string { return \"error\" }\n\nfunc returnsError() error {\n    var e *MyError = nil\n    return e \u002F\u002F Returns non-nil interface containing nil pointer!\n}\n\nif err := returnsError(); err != nil {\n    fmt.Println(\"error is not nil!\") \u002F\u002F This prints\n}\n\n\u002F\u002F Fix: return nil explicitly\nfunc returnsError() error {\n    var e *MyError = nil\n    if e == nil {\n        return nil\n    }\n    return e\n}\n```\n\n### Use Result Before Checking Error (Go 1.25 Fix)\n\nGo 1.25 fixed a compiler bug where using a result before checking for error sometimes didn't panic. Your code should always check errors first.\n\n```go\n\u002F\u002F Wrong: uses f before checking err\nf, err := os.Open(\"file.txt\")\nfmt.Println(f.Name()) \u002F\u002F May panic if f is nil\nif err != nil {\n    return err\n}\n\n\u002F\u002F Correct: always check error first\nf, err := os.Open(\"file.txt\")\nif err != nil {\n    return err\n}\nfmt.Println(f.Name()) \u002F\u002F Safe: err was nil, so f is valid\n```\n\nIn Go 1.21-1.24, a compiler bug sometimes suppressed the panic. Go 1.25 correctly panics, so ensure your code follows the proper pattern.\n\n### Map Iteration Order\n\nMap iteration order is randomized. Do not depend on it.\n\n```go\n\u002F\u002F Wrong: results vary between runs\nfor k, v := range m {\n    results = append(results, v)\n}\n\n\u002F\u002F Correct: sort keys first if order matters\nkeys := slices.Sorted(maps.Keys(m))\nfor _, k := range keys {\n    results = append(results, m[k])\n}\n```\n\n### Slice Append Gotcha\n\nAppend may or may not allocate new backing array.\n\n```go\na := []int{1, 2, 3}\nb := a[:2]\nb = append(b, 4)\n\u002F\u002F a is now [1, 2, 4]! They share backing array\n\n\u002F\u002F Fix: use full slice expression to limit capacity\nb := a[:2:2] \u002F\u002F len=2, cap=2\nb = append(b, 4) \u002F\u002F forces new allocation\n\u002F\u002F a is still [1, 2, 3]\n```\n\n---\n\n## Experimental Features\n\n### encoding\u002Fjson\u002Fv2 (Go 1.25, Experimental)\n\nA new JSON engine is available with improved performance and streaming support.\n\n```go\n\u002F\u002F Enable with: GOEXPERIMENT=jsonv2\n\nimport (\n    \"encoding\u002Fjson\u002Fjsontext\"\n    \"encoding\u002Fjson\u002Fv2\"\n)\n\n\u002F\u002F The v2 API offers:\n\u002F\u002F - Better performance\n\u002F\u002F - Streaming-friendly jsontext package  \n\u002F\u002F - Custom marshalers\u002Funmarshalers per call\n\u002F\u002F - Existing encoding\u002Fjson can use v2 engine internally\n```\n\nThis is experimental and subject to change.\n\n---\n\n## Documentation\n\n### Comment Sentences\n\nComments documenting declarations should be full sentences starting with the name being described.\n\n```go\n\u002F\u002F Request represents a request to run a command.\ntype Request struct{}\n\n\u002F\u002F Encode writes the JSON encoding of req to w.\nfunc Encode(w io.Writer, req *Request) error {}\n```\n\n### Package Comments\n\nPackage comments appear before the package declaration with no blank line.\n\n```go\n\u002F\u002F Package math provides basic constants and mathematical functions.\npackage math\n```\n\n---\n\n## References\n\n1. [Google Go Style Guide](https:\u002F\u002Fgoogle.github.io\u002Fstyleguide\u002Fgo\u002F)\n2. [Uber Go Style Guide](https:\u002F\u002Fgithub.com\u002Fuber-go\u002Fguide)\n3. [Effective Go](https:\u002F\u002Fgo.dev\u002Fdoc\u002Feffective_go)\n4. [Go Code Review Comments](https:\u002F\u002Fgo.dev\u002Fwiki\u002FCodeReviewComments)\n5. [Go 1.23 Release Notes](https:\u002F\u002Fgo.dev\u002Fdoc\u002Fgo1.23)\n6. [Go 1.24 Release Notes](https:\u002F\u002Fgo.dev\u002Fdoc\u002Fgo1.24)\n7. [Go 1.25 Release Notes](https:\u002F\u002Fgo.dev\u002Fdoc\u002Fgo1.25)\n",{},"main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002Fsaisudhir14\u002Fgolang-agent-skill\u002Fgolang-agent-skill",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":7,"skillName":5,"commands":40,"prompt":50,"zipAvailable":51},[41,44,47],{"tool":42,"command":43},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill golang-agent-skill",{"tool":45,"command":46},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill golang-agent-skill",{"tool":48,"command":49},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill golang-agent-skill","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fsaisudhir14\u002Fgolang-agent-skill\u002Fgolang-agent-skill\u002FSKILL.md",true,[],[54,64,74,83,89,96],{"skillNo":55,"name":56,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":60,"publishedAt":26},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[59],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},[61,62,63],"model","model hierarchy","model hierarchy skill",{"skillNo":65,"name":66,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":70,"publishedAt":26},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[69],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},[71,72,73],"MCP","zoom","zoom mcp",{"skillNo":75,"name":76,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":26},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[80,81,82,72],"sdk","zoom apps sdk","apps",{"skillNo":84,"name":85,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":26},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[85],{"skillNo":90,"name":91,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":95,"publishedAt":26},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[94],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},[91],{"skillNo":97,"name":98,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":26},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[98]]