Commit Graph

64 Commits

Author SHA1 Message Date
Nathan Baulch
1b92b5c7db lint: enable 7 more linters (#686)
* lint: enable and fix perfsprint issues

* lint: enable and fix nolintlint issues

* lint: enable and fix godot issues

* lint: enable and fix thelper issues

* lint: enable and fix tparallel issues

* lint: enable and fix paralleltest issues

* lint: enable and fix predeclared issues
2025-09-25 13:18:25 +02:00
Nathan Baulch
2911f93956 fix: panic when passing -1 to Drop (#688) 2025-09-25 13:11:52 +02:00
Samuel Berthe
ec86b574ed feat: adding TrimXXX methods (#683) 2025-09-25 04:15:30 +02:00
Nathan Baulch
52d31f788f lint: fix CI warnings and avoid named return parameters (#682) 2025-09-25 03:44:33 +02:00
Alex Klepov
21a523ddc0 Added Cut, CutPrefix, CutSuffix (#666)
* Added Cut, CutPrefix, CutSuffix

* fix readme

* Clarify Cut, CutPrefix, and CutSuffix documentation

Updated descriptions and examples for Cut, CutPrefix, and CutSuffix functions to clarify usage with slices.

* Refactor Cut, CutPrefix, and CutSuffix functions

* Update slice_test.go

---------

Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
2025-09-25 01:52:48 +02:00
Nathan Baulch
41cbf0fd2b feat: preserve type alias in DropByIndex and WithoutBy (#675)
* lint: pin golangci-lint version

* feat: preserve type alias in WithoutBy

* feat: preserve type alias in DropByIndex

---------

Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
2025-09-24 22:57:40 +02:00
Nathan Baulch
7170719ec0 lint: unit test improvements (#674)
* lint: pin golangci-lint version

* lint: use is.Empty where possible

* lint: use is.ElementsMatch for unsorted slices

* lint: remove redundant is.Len assertions

* lint: use is.Zero to assert zero structs

* fix: misc assertion issues

* lint: more consistent test case pattern

* fix: reversed expect/actual assert values

* lint: use is.ErrorIs and is.EqualError for errors

* Update golangci-lint version in workflow

---------

Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
2025-09-24 21:02:52 +02:00
Nathan Baulch
b5e290abe0 fix: more consistent panic strings (#678)
* lint: pin golangci-lint version

* fix: more consistent panic strings

* Update golangci-lint version in workflow

Updated golangci-lint action version to v2.4.

---------

Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
2025-09-24 21:02:02 +02:00
Nathan Baulch
3e11f11781 docs: grammar improvements (#673)
* lint: pin golangci-lint version

* docs: grammar fixes

* docs: remove "truthy" terminology

* docs: remove "array" terminology

* docs: grammar fixes

* Update .github/workflows/lint.yml

---------

Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
2025-09-24 20:59:41 +02:00
Nathan Baulch
76b76a7adb lint: Apply testifylint linter recommendations (#669) 2025-09-20 00:50:00 +02:00
overbeck
0fa0632c0f Perf(slice): Optimize iteration function parameters and add test cases (#587)
- Modify the iteration function parameters in the UniqueBy, GroupByMap, and Keyify functions to use index access for collection elements.
- Optimize parameter naming in the GroupByMap function to improve code readability.
- Add test cases for the GroupByMap function to cover different types of inputs.

Co-authored-by: ShuQingZai <overbeck.jack@outlook.com>
2025-02-17 00:10:10 +01:00
Samuel Berthe
ce12685a40 fix(groupbymap): remove second iteratee and add test+example+doc 2025-01-28 20:25:04 +01:00
Samuel Berthe
124d3004de feat: adding FilterSliceToMap (#581) 2025-01-26 23:32:59 +01:00
Samuel Berthe
27d2554396 fix: renaming SliceToSet to Keyify 2025-01-25 23:26:53 +01:00
nicklausliu
4b7879b22d feat: add more duplicate test 2025-01-25 23:23:30 +01:00
nicklausliu
b4412ea1af feat: add SliceToSet 2025-01-25 23:23:30 +01:00
nicklaus-dev
c32746c703 feat: add UniqMap (#527) 2025-01-24 22:21:01 +01:00
Nathan Baulch
db0f4d2171 Tidy up (#519) 2024-08-22 01:17:02 +02:00
Sianao Luo
cbfd1c6286 add ForEachCondition implement (#485)
* add ForEachCondition implement

* add example and test code

* rename ForEachCondition() to ForEachWhile()

* update test and example code

* rename ExampleForForEachWhile() to ExampleForEachWhile()
2024-07-15 19:28:57 +02:00
Mihir Gandhi
9e343973a4 fix: chunk memory leak (#491) 2024-07-15 19:16:03 +02:00
Owen Gong
52e17faeec Added DropByIndex helper for slice (#398)
* added DropByIndex helper

---------

Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
2024-06-30 00:38:34 +02:00
Samuel Berthe
3ba93a16cc feat: preserve type alias of slices and maps (see #365) 2024-06-30 00:04:08 +02:00
Felipe Gasper
de419c7571 Make Filter() preserve type. (#365)
* Update slice.go

* add test
2024-06-29 23:33:19 +02:00
Samuel Berthe
2ec43f41f4 Revert "Add new method Concat (#376)" (#479)
This reverts commit 940ded8b03.
2024-06-29 22:41:09 +02:00
Jason Zhang
940ded8b03 Add new method Concat (#376)
* Add new method Concat

---------

Co-authored-by: Zhang Jie (Jason) <jie.zhang@grabtaxi.com>
Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
2024-06-29 21:53:58 +02:00
wick
fe16ff7d23 Add slice Splice an element or multiple elements at index i. (#371)
* Add slice Splice an element or multiple elements at index i.

* Update README.md

* Update slice.go

* Update slice.go

* Update README.md

* Update slice_test.go

---------

Co-authored-by: wenlingang <lingang.wen@longbridge.sg>
Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
2024-06-29 20:25:42 +02:00
Samuel Berthe
80bb7cefc6 feat: adding RejectMap (#473) 2024-06-27 16:17:40 +02:00
Samuel Berthe
91b5d9480e feat: adding FilterReject (#472) 2024-06-27 16:12:34 +02:00
Benn Huang
dba7426c43 fix (#256) 2022-11-15 20:36:05 +01:00
VictorAssunc
640e00c286 chore: test coverage improvement (#240)
* chore: improves channel functions test coverage

* chore: improves errors functions test coverage

* chore: improves map functions test coverage

* chore: improves parallel slice functions test coverage

* chore: improves slice functions test coverage

* fix: uses atomic counter on parallel/slice_test

* Update channel_test.go

Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
2022-10-22 19:05:07 +02:00
Samuel Berthe
e3f7dab5ce doc: improve doc for lo.Interleave 2022-10-10 23:03:09 +02:00
dillonstreator
fd5527feb6 add Interleave helper to slices (#155)
* initial interleave working

* add nil case

* Update README.md

Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
2022-10-10 22:53:40 +02:00
Samuel Berthe
f44773e344 feat: adding CountValuesBy 2022-10-10 21:26:19 +02:00
orccn
5f3a5c0f60 Add CountValues function (#200)
* Flatten: named return parameters

* Add CountValues function

* fix S1036: unnecessary guard around map access

* update README.md

Co-authored-by: 刘鹏宇 <liupengyu@showmac.com>
2022-10-10 20:59:41 +02:00
Samuel Berthe
cc3aa2287b doc(examples): adding go playground examples (string, map, slice, condition, math) 2022-10-03 22:17:15 +02:00
Samuel Berthe
31f3bc3a85 test: parallel tests everywhere (#228) 2022-10-02 21:38:26 +02:00
Samuel Berthe
7a82347b1b doc: adding IsSorted and IsSortedByKey 2022-07-24 22:57:58 +02:00
fffzlfk
add5ee4bb2 feat: add issorted (#152) 2022-07-24 22:47:12 +02:00
xhdnoah
c6e4913100 Add ReduceRight (#178)
Co-authored-by: xuhaidong_dxm <xuhaidong01@duxiaoman.com>
2022-07-24 19:20:35 +02:00
elvis
20debbb39e add Associate function (#185) 2022-07-24 19:15:07 +02:00
Syuparn
252d72a238 feat: adding Compact (#154)
Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
2022-07-03 21:30:17 +02:00
Nonua
1493eadd47 feat: add Slice (#171)
feat: add `Slice`
2022-07-03 19:07:41 +02:00
lu4p
305f565368 remove unnecessary explicit typeparams (#134) 2022-05-11 13:10:36 +02:00
Samuel Berthe
e0853ca970 feat: Add FromAnySlice (#133)
* feat: adding FromAnySlice helper
2022-05-10 15:43:34 +02:00
Adam Szaraniec
fda38bb721 rename to toAnySlice 2022-05-10 16:49:21 +04:00
Adam Szaraniec
a9556597dc Add function ToInterfaceSlice which return slice with all elements mapped to any type 2022-05-10 14:33:47 +04:00
Samuel Berthe
d2d7090565 fix(lo.Shuffle): add more items to tests, to prevent same result than initial value 2022-05-02 14:44:15 +02:00
Samuel Berthe
94d54a8f47 feat: adding runelength 2022-05-01 00:22:36 +02:00
Samuel Berthe
d22a2a264d feat: adding Replace and ReplaceAll 2022-04-30 23:23:09 +02:00
Samuel Berthe
2552cd5e0d feat: adding RepeatBy 2022-04-30 21:18:08 +02:00