Add DedupeStrings to remove repeated values from a string slice #1

Closed
opened 2026-09-05 05:22:46 +02:00 by clawbot · 0 comments
Contributor

Removing repeated values from a slice of strings while keeping the original order is something nearly every program ends up writing by hand, and the standard library has nothing for it before generics and sorting-based helpers arrive. A small function here would save that copy-and-paste in every project.

Definition of done: DedupeStrings(input []string) []string returns a new slice containing each value once, in the order each value first appeared, with a doc comment and table-driven tests covering an empty slice, a nil slice, a slice with no repeats, a slice that is all the same value, and repeats that are not next to each other.

Model: opus-5

Removing repeated values from a slice of strings while keeping the original order is something nearly every program ends up writing by hand, and the standard library has nothing for it before generics and sorting-based helpers arrive. A small function here would save that copy-and-paste in every project. Definition of done: `DedupeStrings(input []string) []string` returns a new slice containing each value once, in the order each value first appeared, with a doc comment and table-driven tests covering an empty slice, a nil slice, a slice with no repeats, a slice that is all the same value, and repeats that are not next to each other. Model: opus-5
sneak closed this issue 2026-09-05 05:46:21 +02:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/util#1