Go Modernize logo

Go Modernize

Community
eduardo-sl
go-modernize

Modernize Go code to use current language features and standard library additions, Go 1.21 through 1.27: generics and generic methods, log/slog, errors.Join, slices/maps, iterators, encoding/json/v2, stdlib uuid. Use when: "modernize", "update to modern Go", "use generics", "replace interface{}", "upgrade Go version", "slog", "errors.Join", "range over func", "iterators". Not for: general style (go-coding-standards), error philosophy (go-error-handling), logging architecture (go-observability).

Overview

Publishereduardo-sl
Repositorygo-agent-skills
Skill namego-modernize
Stars
86
Forks
11
Bundled files
4
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 4 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by eduardo-sl on GitHub. Read the source before you install it.

Installation

Install the Go Modernize AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/eduardo-sl/go-agent-skills/tree/main/skills/(code-quality)/go-modernize
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.

Use it in TypingMind

Enable Go Modernize in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Go Modernize on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Go Modernize is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Go Modernize

Go evolves. Code written for Go 1.16 should not look the same as code targeting Go 1.27. Modernize incrementally — update go.mod, then adopt new patterns.

Never adopt a feature above the go directive in go.mod. Raise the directive deliberately, in its own commit, and only to a version the project's CI and deployment images actually run.

Detailed reference material, loaded on demand:

  • references/generics.md — replacing interface{} with type parameters, constraints, generic containers, when NOT to use generics.
  • references/stdlib-migrations.md — before/after examples for slog, errors.Join, slices/maps helpers, range-over-int, and iterators.
  • references/go1.27.md — generic methods, CutLast, URL/Values Clone, big.Int.Divide, stdlib uuid, json/v2 semantics, synctest and httptest additions, tooling changes.
  • references/version-bump.md — procedure and per-release checklist (1.25-1.27) for what can break when the go directive is raised.

Read a reference file only when the summary below is not enough.

Operating Modes

  • Inline (default — the developer is working on something else): modernize only the lines you are already changing. Note other opportunities once, at the end, each with the gain it brings; do not touch unrelated files — an unrequested sweep buries the real change in churn. If a suggestion is declined, do not raise it again in the session; if the developer wants that remembered, add one line to the project's agent-config file (CLAUDE.md, AGENTS.md).
  • Version bump (raising the go directive): a behavior change even with no source edits. Follow references/version-bump.md — prerequisites, then the per-release breakage checklist — before adopting any feature.
  • Sweep (asked to modernize a package or the module): run the procedure below and land one commit per category — go fix output, deprecated APIs, language features, stdlib helpers, tests — each green on build and tests. The categories are independent; if your environment supports parallel sub-agents, give each one a category and work on a separate branch or worktree.

Priority Order

Apply in this order when time is limited:

  1. Correctness and security — errors.Is/As instead of ==, http.NewRequestWithContext, os.Root for user-supplied paths, crypto/rand wherever randomness protects something, deprecated x/crypto packages replaced by their stdlib versions.
  2. Readability — any, min/max, range over int, slices/maps, cmp.Or, sync.OnceValue, wg.Go, errors.AsType.
  3. Gradual — iterators, logger migration to slog, go.mod tool directives, dropping dependencies the stdlib now covers.

Modernization Procedure

  1. Check the go directive in go.mod — it caps which features you can use. Raising it is the Version bump mode, never a side effect of a feature change.

  2. Run the official modernizers first — they find and fix the mechanical migrations automatically:

    bash
    # Go 1.26+ — the modernizers now live in go fix
    go fix ./...
    
    # Go 1.25 and earlier, or a modernizer newer than your toolchain
    go run golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest -fix ./...

    Both rewrite source in place. Commit before running, and review the diff. If neither command is available, apply the table below manually.

  3. Scan the table below for the judgment-based migrations the analyzer does not cover (generics, iterators, logger replacement) and apply them case by case.

  4. Run go build ./... and the test suite after each group of changes.

Feature Table by Go Version

Go VersionFeatureAction
1.13+errors.Is, errors.AsReplace == error comparisons
1.13+http.NewRequestWithContextReplace http.NewRequest
1.16+embedReplace go-bindata / packr
1.18+GenericsReplace interface{} utility functions
1.20+errors.JoinReplace manual error accumulation
1.21+log/slogReplace log for structured logging
1.21+slices, mapsReplace hand-written slice/map utilities
1.21+min, max builtinsReplace math.Min/math.Max (float64-only)
1.21+sync.OnceValue, sync.OnceFuncReplace sync.Once + package var pairs
1.22+Range over intReplace for i := 0; i < n; i++
1.22+Per-iteration loop variablesDelete v := v shadow copies (only once go.mod says 1.22+)
1.22+math/rand/v2Replace math/rand; drop rand.Seed
1.22+cmp.OrReplace "first non-zero value" if-chains
1.22+ServeMux method + wildcard patternsReplace a router dependency used only for GET /users/{id}
1.23+Range over funcReplace callback-based iteration
1.23+unique.MakeReplace hand-rolled string interning
1.24+for b.Loop()Replace for range b.N in benchmarks
1.24+t.Context()Replace context.Background() in tests
1.24+os.RootReplace manual path-traversal checks
1.24+go.mod tool directiveReplace the tools.go blank-import file
1.24+runtime.AddCleanupReplace runtime.SetFinalizer
1.24+omitzero struct tagReplace omitempty where Go zero values (e.g. time.Time{}) must be omitted
1.24+strings.SplitSeq, strings.Lines, FieldsSeqReplace Split when the slice is only ranged over
1.24+crypto/sha3, crypto/hkdf, crypto/pbkdf2Replace the golang.org/x/crypto versions
1.24+crypto/rand.TextReplace hand-rolled random token encoders
1.25+testing/synctestReplace time.Sleep in concurrency tests
1.25+sync.WaitGroup.GoReplace wg.Add(1) + go func(){defer wg.Done()}
1.25+reflect.TypeAssertReplace v.Interface().(T) (no allocation)
1.25+Container-aware GOMAXPROCSRemove go.uber.org/automaxprocs
1.26+errors.AsTypeReplace errors.As with a declared target variable
1.26+slog.NewMultiHandlerReplace hand-written fan-out handlers
1.26+new(expr)Replace a temp variable taken by address
1.26+httputil.ReverseProxy.RewriteReplace the deprecated, unsafe Director hook
1.27+Generic methodsReplace package-level generic helpers that belong to one type (not when an interface must expose them)
1.27+Promoted fields as literal keysReplace Outer{Inner: Inner{ID: x}} nesting
1.27+strings.CutLast, bytes.CutLastReplace LastIndex + slicing
1.27+url.URL.Clone, url.Values.CloneReplace hand-written deep copies
1.27+big.Int.DivideReplace QuoRem + sign correction
1.27+stdlib uuidReplace google/uuid for v4/v7 IDs
1.27+encoding/json/v2Adopt per call site — stricter semantics, see reference
1.27+synctest.Sleep, httptest.NewTestServerReplace time.Sleep+Wait and socket-bound test servers
1.27+testing/cryptotest.SetGlobalRandomReplace tls.Config.Rand in tests

Worked Migrations

Before/after examples for every row above live in references/stdlib-migrations.md (stdlib and language features) and references/generics.md (type parameters). Test-specific migrations — t.Context(), b.Loop(), synctest — are owned by the go-test-quality skill.

Verification Checklist

  1. go.mod version matches the features used in the codebase
  2. No interface{} where any or type parameters would be clearer
  3. log/slog used instead of log.Printf for structured logging
  4. errors.Join used instead of manual error string concatenation
  5. slices.Contains, slices.SortFunc, maps.Clone replace hand-written loops
  6. Range over int (for i := range n) used where applicable
  7. http.NewRequestWithContext used instead of http.NewRequest
  8. No sort.Slice — use slices.SortFunc with cmp.Compare
  9. Generics used for type-safe containers and utilities, not overused for trivial cases
  10. Third-party dependencies evaluated against stdlib alternatives added in recent Go versions
  11. sync.WaitGroup.Go used instead of manual Add/Done pairs (Go 1.25+)
  12. Tests use t.Context() and for b.Loop() (Go 1.24+)
  13. tools.go replaced by the go.mod tool directive (Go 1.24+)

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Go Modernize AI skill do?

Modernize Go code to use current language features and standard library additions, Go 1.21 through 1.27: generics and generic methods, log/slog, errors.Join, slices/maps, iterators, encoding/json/v2, stdlib uuid. Use when: "modernize", "update to modern Go", "use generics", "replace interface{}", "upgrade Go version", "slog", "errors.Join", "range over func", "iterators". Not for: general style (go-coding-standards), error philosophy (go-error-handling), logging architecture (go-observability).

Why use Go Modernize on TypingMind?

Because you install it once and use it with any model. Go Modernize is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Go Modernize in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/eduardo-sl/go-agent-skills/tree/main/skills/(code-quality)/go-modernize. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Go Modernize?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Go Modernize?

As many as you like. As long as a model supports skills, you can use Go Modernize with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Go Modernize AI skill free?

Yes. It is published on GitHub by eduardo-sl under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇