roninforge/roninforge-go/go-modernize

Claude Code and agent skill by roninforge/roninforge-go

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Migrate older Go code to 1.22+ idioms: ioutil -> io/os, log.Println -> slog, interface{} -> any, manual mux routing -> http.ServeMux method patterns, drop v := v shadow, math/rand -> math/rand/v2.

Install

npx vskill@latest install roninforge/roninforge-go/go-modernize

SKILL.md

The same SKILL.md was published earlier as roninforge/roninforge-go/go-modernize.

Modernize Go to 1.22+

When to Use

When inheriting or auditing a Go codebase that predates 1.22 patterns, or when an AI-generated codebase uses outdated idioms.

Instructions

Apply each transformation in order. Run go build ./... and go test ./... after each step.

Step 1: Bump Go version

In go.mod:

go 1.24

Set this to the lowest version the project will support. go 1.22 minimum for the patterns in this skill.

Step 2: ioutil -> io / os
bash
grep -rln 'io/ioutil' --include='*.go' .

Replace:

  • ioutil.ReadAll(r) -> io.ReadAll(r)
  • ioutil.ReadFile(p) -> os.ReadFile(p)
  • ioutil.WriteFile(p, b, mode) -> os.WriteFile(p, b, mode)
  • ioutil.TempFile(...) -> os.CreateTemp(...)
  • ioutil.TempDir(...) -> os.MkdirTemp(...)
  • ioutil.NopCloser(r) -> io.NopCloser(r)
  • ioutil.Discard -> io.Discard

Then remove the import.

Step 3: interface{} -> any
bash
grep -rln 'interface{}' --include='*.go' . | xargs sed -i.bak 's/interface{}/any/g'

Review each change. interface{} may legitimately appear in generated code; do not touch generated files (*_gen.go, *.pb.go).

Step 4: log -> slog

Replace package-level log calls:

go
// before
log.Printf("user %s logged in", id)
log.Fatal("db connect:", err)
// after
slog.InfoContext(ctx, "user login", "user_id", id)
return fmt.Errorf("db connect: %w", err) // and exit non-zero from main

At the top of main:

go
logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
slog.SetDefault(logger)

log.Fatal is the worst offender - it calls os.Exit(1) which skips deferred funcs. Always replace with a returned error.

Step 5: Routing -> http.ServeMux method patterns (1.22+)

If the codebase has a hand-rolled router or third-party (mux.Router, chi.Router) and the routing is simple, port to stdlib:

go
mux := http.NewServeMux()
mux.HandleFunc("GET /users/{id}", h.GetUser)
mux.HandleFunc("POST /users", h.CreateUser)
mux.HandleFunc("DELETE /users/{id}", h.DeleteUser)
// in handler
id := r.PathValue("id")

If the project uses middleware chains or wildcards, leave the existing router and apply other rules.

Step 6: Drop unnecessary loop-variable shadowing

In 1.22+, for _, v := range items creates a fresh v each iteration. The v := v shadow is unnecessary.

bash
grep -rnE '^\s*[a-z]+ := [a-z]+\s*$' --include='*.go' . -B 2 | grep 'for .* range'

Remove the shadow line.

Step 7: math/rand -> math/rand/v2

For non-cryptographic randomness:

go
// before
import "math/rand"
n := rand.Intn(100)
// after
import "math/rand/v2"
n := rand.IntN(100)

For cryptographic randomness (tokens, passwords, IDs), use crypto/rand:

go
import "crypto/rand"
token := rand.Text() // 1.24+, returns base32 26-char string

Never use math/rand for security-sensitive randomness.

Step 8: Error wrapping

Use the go-error-wrap skill for this step.

Step 9: Verify
bash
go mod tidy
go build ./...
go vet ./...
staticcheck ./...
go test -race ./...

If a third-party linter is available, also run golangci-lint run.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
5

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/roninforge/roninforge-go/go-modernize/badge)](https://verified-skill.com/skills/roninforge/roninforge-go/go-modernize)

Something wrong with this skill or its page? Tell us.