Skip to content

[plan] Remove unnecessary []byte casts in pkg/console golden tests #24056

@github-actions

Description

@github-actions

Objective

Remove unnecessary []byte() casts when passing string values to golden.RequireEqual in pkg/console/golden_test.go.

Context

Source: discussion #24035 — Go module review of charmbracelet/x/exp/golden.

The RequireEqual function is generic:

func RequireEqual[T []byte | string](tb testing.TB, out T)

But the current test code always converts strings to []byte:

// Current (unnecessary allocation + cast)
golden.RequireEqual(t, []byte(output))
golden.RequireEqual(t, []byte(fullOutput.String()))

// Simplified (no cast needed)
golden.RequireEqual(t, output)
golden.RequireEqual(t, fullOutput.String())

Files to Modify

  • pkg/console/golden_test.go — remove all []byte(...) wrapping around string arguments to golden.RequireEqual

Acceptance Criteria

  • All []byte(string_value) casts removed when calling golden.RequireEqual
  • All 38 golden tests in pkg/console still pass (go test -run TestGolden ./pkg/console/)
  • No other changes to test logic

Generated by Plan Command for issue #discussion #24035 ·

  • expires on Apr 4, 2026, 10:44 AM UTC

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions