28 Commits

Author SHA1 Message Date
Samuel Berthe e9ad51b03a perf: add map capacity hints to Mode and it.UniqKeys/UniqValues (#837)
- Mode: make(map[T]int) → make(map[T]int, len(collection))
- it.UniqKeys: compute total size from input maps for seen map hint
- it.UniqValues: compute total size from input maps for seen map hint

Avoids repeated map rehashing as entries are added.
2026-03-06 17:10:17 +01:00
Samuel Berthe fa095e4b4f fix(doc): fix go playground demo URL (#832)
* fix(doc): fix go playground demo URL

* fix(doc): add more go playground demo URL
2026-03-06 00:09:59 +01:00
Samuel Berthe 153f867680 feat: adding MeanByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe e9037c6e8c feat: adding ProductByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 12e2b4ceb4 feat: adding SumByErr helper 2026-03-02 16:06:51 +01:00
d-enk b0b5cc3adf perf: preallocate result slice in RangeWithSteps (#820)
- RangeWithSteps now preallocates result slice using math.Ceil for better performance
- Fix edge cases for floating point values with small steps
- Add test cases for float and custom type validation
- Rename TestRangeClose → TestRangeWithSteps for consistency
- Simplify ChunkEntries chunk count calculation using ((count-1)/size)+1 formula
2026-02-25 20:48:26 +01:00
d-enk 2859d7382f perf: use Ternary() instead If().Else() in Range/RangeFrom (#770)
No allocs in it.Range, it.RangeFrom

Add more tests
2026-01-13 11:34:46 +01:00
d-enk 123d5c2531 refactor: remove some redundant checks (#771) 2026-01-12 20:42:12 +01:00
Nathan Baulch f5aac81cc0 lint: enable gofumpt extra rules (#690)
Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
2025-09-26 13:32:59 +02:00
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 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
Samuel Berthe 3bc887c57c doc: adding go playground examples 2025-09-23 14:54:30 +02:00
Samuel Berthe 9c8308ffda Style add golangci config (#670)
* style(lint): gofumpt

* style(lint): errcheck

* style(lint): revive

* style(lint): gocritic

* style(lint): forcetypeassert

* style(lint): add .golangci.yml

* oops
2025-09-20 01:37:51 +02:00
ghosx bededfed30 feature: add Mode function with tests and documentation (#644)
* Update README.md

Fixed the error in the usage example of lo.Latest in readme.md

use []time.Time{…} (value of type []time.Time) as time.Time value in argument to lo.Latest

* Update README.md

* feature: add Mode function with tests and documentation

---------

Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
2025-07-07 02:05:39 +02:00
Mark Hildreth 82f753a511 Fix Product and ProductBy documentation (#647)
These functions stated that if empty they return 0, but in actuality the code returns 1
2025-07-02 17:28:50 +02:00
Samuel Berthe 96d5482643 fix(product): fix empty slice behavior (#583) (#584) 2025-01-28 12:35:04 +01:00
Samuel Berthe 2bdcacae5e doc: add example for Product and ProductBy 2025-01-27 01:05:21 +01:00
JohnDevitt 1c1dfd9d29 feat: add Product and ProductBy functions (#566)
Co-authored-by: John.Devitt@cdp.net <JohnDevitt@Mac.cust.communityfibre.co.uk>
2025-01-27 01:02:11 +01:00
Nathan Baulch db0f4d2171 Tidy up (#519) 2024-08-22 01:17:02 +02:00
Trim21 42a90a0c7b remove golang.org/x/exp since it doesn't follow go 1 compatibility promise (#478)
* fix

* mod tidy

* remove test

* redirect cmp.Ordered

* fix

* fix

* fix
2024-06-29 18:03:44 +02:00
Samuel Berthe 61209816d1 feat: speed up loops by reducing allocations (#475) 2024-06-28 01:35:57 +02:00
Usman Ahmed 97074eeae7 Adding Mean and MeanBy (#414)
* feat: create Mean for ints and floats

* feat: create MeanBy for ints and floats

* chore: add example tests for mean Mean and MeanBy
2024-06-27 13:45:28 +02:00
Samuel Berthe 7887963db8 feat: name each callback/iteratee/predicate arguments in order to improve autocompletion
closes #242
2022-10-13 22:25:33 +02:00
Samuel Berthe ce01c4c64b doc: improve doc for lo.Sum 2022-10-10 22:25:14 +02:00
JC Dansereau 6f0207afd8 add slice sum (#210)
Co-authored-by: JC Dansereau <jcdansereau@hortau.com>
2022-10-10 22:18:57 +02:00
Samuel Berthe cc3aa2287b doc(examples): adding go playground examples (string, map, slice, condition, math) 2022-10-03 22:17:15 +02:00
Pål Fossmo 9b345886aa Moved SumBy function to math.go.
Changed from data types to constraints in SumBy function signature.
2022-04-30 21:06:31 +02:00
Samuel Berthe cf11153875 feat: adding Clamp 2022-04-12 21:58:28 +02:00