Skip to content

fix(mutable): move Fill to slice.go to export it properly - #1053

Open
mazkev wants to merge 1 commit into
samber:masterfrom
mazkev:fix/mutable-fill-export
Open

mazkev wants to merge 1 commit into
samber:masterfrom
mazkev:fix/mutable-fill-export

Conversation

@mazkev

@mazkev mazkev commented Oct 27, 2026

Copy link
Copy Markdown

Describe your changes

In the mutable package, func Fill was accidentally declared inside mutable/slice_example_test.go instead of mutable/slice.go.

Because Go omits _test.go files during compilation for external consumers, mutable.Fill was not actually exported in the public API when importing github.com/samber/lo/mutable (undefined: mutable.Fill).

Changes made:

  1. Move func Fill: Moved from mutable/slice_example_test.go to mutable/slice.go.
  2. Add ExampleFill: Added a runnable ExampleFill() in mutable/slice_example_test.go to verify the example and keep documentation examples complete.
  3. Update Documentation:
    • Updated sourceRef in docs/data/mutable-fill.md to point to mutable/slice.go#L78.
    • Fixed example snippet in docs/data/mutable-fill.md to use lom.Fill instead of lo.Fill.

Verification:

  • go doc ./mutable now correctly lists:
    func Fill[T any, Slice ~[]T](collection Slice, initial T)

Fill was accidentally defined in slice_example_test.go instead of slice.go, causing it to not be exported as part of the public mutable package.

This moves func Fill into slice.go, adds ExampleFill() in slice_example_test.go, and updates the source reference and example in docs/data/mutable-fill.md.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant