Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Road to replacing slice operations with standard lib functions #664

Open
muety opened this issue Aug 14, 2024 · 1 comment
Open

Road to replacing slice operations with standard lib functions #664

muety opened this issue Aug 14, 2024 · 1 comment

Comments

@muety
Copy link
Owner

muety commented Aug 14, 2024

As we're trying to use as few external dependencies as possible in Wakapi, I looked into how duke-git/lancet/slice might be replaced with latest standard library methods.

The following table lists all slice methods we're currently using in the code base. However, looks like there's not yet an stdlib equivalent for all of them (happy to learn otherwise).

Of course, things like Filter could also be written out as a loop, however, I prefer code compactness and readability in this case.

lancet method stdlib method lo method
slice.Contain slices.Contains tbd
slice.ContainBy slices.ContainsFunc tbd
slice.Find slices.IndexFunc (not quite the same) tbd
slice.Filter - tbd
slice.Unique slices.Sorted + slices.Compact tbd
slice.Map - tbd
slice.SortByField slices.SortedFunc tbd
slice.GroupWith - (feature request) tbd
@muety
Copy link
Owner Author

muety commented Sep 7, 2024

Introducing slog-sentry unfortunately brought in lo as another dependency. It does pretty much exactly the same as lancet (I went for lancet, because lo didn't exist at the time (shortly after Go generics were introduced)).

To eliminate lancet as a dependency, I'd propose to:

  1. Replace all function calls with stdlib equivalents wherever possible
  2. Replace all remaining ones with lo euqivalents
  3. Hopefully none are left

Need to fill another column for lo in the table above.

Whoever wants to jump onto this refactoring, go for it! It's super low-prio, though, because there won't be an actual benefit for the user. Only advantage will be one less dependency and thus adds a bit to keeping Wakapi light-weight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant