← All recipes
Moderne licensed

Migrate golang.org/x/exp/slog to log/slog

Recipe IDorg.openrewrite.golang.migration.MigrateXExpSlogToStdlibArtifactgithub.com/moderneinc/recipes-go

Repoint golang.org/x/exp/slog at the standard library log/slog, added in Go 1.21, and rename the context-taking helpers the standard library spells differently: DebugCtx, InfoCtx, WarnCtx and ErrorCtx become DebugContext, InfoContext, WarnContext and ErrorContext. x/exp carries both spellings, so a file already on the Context ones is a plain path swap.

Single recipeProprietary

Usage

This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe org.openrewrite.golang.migration.MigrateXExpSlogToStdlib

If the recipe isn’t available locally, install it with:

mod config recipes go install github.com/moderneinc/recipes-go