Skip to content

Commit 39e418f

Browse files
committed
doc: adding a "contributing" page
1 parent 1b3cb42 commit 39e418f

File tree

8 files changed

+114
-31
lines changed

8 files changed

+114
-31
lines changed

docs/data/core-crossjoinbyx.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ similarHelpers:
2323
- core#tuple#unzipbyx
2424
- core#slice#product
2525
- core#slice#productby
26-
position: 0
26+
position: 60
2727
---
2828

2929
Computes a cartesian product and projects each combination through a function. Variants support 2 up to 9 input slices.

docs/data/core-crossjoinx.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ similarHelpers:
2121
- core#intersect#product
2222
- core#intersect#productby
2323
- core#map#entries
24-
position: 0
24+
position: 10
2525
---
2626

2727
Computes the cartesian product of input slices, returning tuples of all combinations. Variants support 2 up to 9 input slices.

docs/data/core-tuplex.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,18 @@ sourceRef: tuples.go#L5
55
category: core
66
subCategory: tuple
77
signatures:
8-
- "func T2[A, B any](a A, b B) Tuple2[A, B]"
8+
- "func T2[A, B any](a A, b B) lo.Tuple2[A, B]"
9+
- "func T3[A, B, C any](a A, b B, c C) lo.Tuple3[A, B, C]"
10+
- "func T4[A, B, C, D any](a A, b B, c C, d D) lo.Tuple4[A, B, C, D]"
11+
- "func T5[A, B, C, D, E any](a A, b B, c C, d D, e E) lo.Tuple5[A, B, C, D, E]"
12+
- "func T6[A, B, C, D, E, F any](a A, b B, c C, d D, e E, f F) lo.Tuple6[A, B, C, D, E, F]"
13+
- "func T7[A, B, C, D, E, F, G any](a A, b B, c C, d D, e E, f F, g G) lo.Tuple7[A, B, C, D, E, F, G]"
14+
- "func T8[A, B, C, D, E, F, G, H any](a A, b B, c C, d D, e E, f F, g G, h H) lo.Tuple8[A, B, C, D, E, F, G, H]"
15+
- "func T9[A, B, C, D, E, F, G, H, I any](a A, b B, c C, d D, e E, f F, g G, h H, i I) lo.Tuple9[A, B, C, D, E, F, G, H, I]"
916
playUrl: https://go.dev/play/p/IllL3ZO4BQm
1017
variantHelpers:
1118
- core#tuple#tx
19+
- core#tuple#tuplex
1220
similarHelpers:
1321
- core#tuple#unpackx
1422
- core#tuple#zipx
@@ -26,7 +34,7 @@ Variants:
2634

2735
```go
2836
t := lo.T3(1, "a", true)
29-
// Tuple3[int, string, bool]{A:1, B:"a", C:true}
37+
// lo.Tuple3[int, string, bool]{A:1, B:"a", C:true}
3038
```
3139

3240

docs/data/core-unzipx.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ similarHelpers:
2424
- core#tuple#unzipbyx
2525
- core#slice#mapkeys
2626
- core#slice#mapvalues
27-
position: 40
27+
position: 30
2828
---
2929

3030
Splits a slice of tuples back into multiple parallel slices. Variants support tuple sizes from 2 to 9.

docs/docs/about.md

Lines changed: 55 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,58 @@ sidebar_position: 0
88

99
**samber/lo** is a Lodash-style utility library for Go that brings the power and convenience of functional programming helpers to the Go ecosystem. Born from the need for more expressive and concise data manipulation, `lo` fills the gaps between Go's standard library and the complex data transformations that modern applications require.
1010

11-
## Why `lo` Exists
11+
![logo](../static/img/functional-gopher.png)
12+
13+
**Why `lo` Exists**
1214

1315
Go's standard library is excellent for many use cases, but it lacks the higher-level abstractions that developers coming from JavaScript, Python, or other languages often miss. While Go 1.18 introduced generics, the standard library's `slices` and `maps` packages only cover about 5-10 basic helpers. `lo` provides hundreds of additional utilities that make everyday programming tasks more enjoyable and less error-prone.
1416

15-
## Design Philosophy
17+
**The name "lo"**
1618

17-
### 1. **Type Safety Through Generics**
18-
Every function in `lo` is built on Go 1.18+ generics, ensuring compile-time type safety without sacrificing flexibility. This eliminates runtime type assertions and reduces bugs.
19+
I wanted a short and memorable name, similar to "Lodash". It's easy to type and no existing Go package was using this name, making it unique in the ecosystem.
1920

20-
### 2. **Immutable by Default**
21-
The main `lo` package follows functional programming principles by returning new collections rather than modifying existing ones. This predictability makes code easier to reason about and test.
21+
## 🚀 Install
2222

23-
### 3. **Performance When Needed**
24-
For performance-critical scenarios, `lo` offers specialized packages:
25-
- `lo/mutable`: In-place operations that modify collections directly
26-
- `lo/parallel`: Concurrent processing with built-in worker pools
27-
- `lo/it`: Lazy evaluation using Go 1.23+ iterators
23+
```go
24+
go get -u github.com/samber/lo@v1
25+
```
2826

29-
### 4. **Minimal Dependencies**
30-
`lo` has zero dependencies outside the Go standard library. This choice ensures reliability, security, and avoids dependency hell.
27+
This library is v1 and follows SemVer strictly.
28+
29+
No breaking changes will be made to exported APIs before v2.0.0.
30+
31+
This library has no dependencies outside the Go standard library.
32+
33+
## 💡 Usage
34+
35+
You can import lo using:
3136

32-
## Key Design Decisions
37+
```go
38+
import (
39+
"github.com/samber/lo"
40+
lop "github.com/samber/lo/parallel"
41+
lom "github.com/samber/lo/mutable"
42+
)
43+
```
3344

34-
### Function Naming
35-
Functions follow familiar patterns from Lodash and other functional libraries, making the learning curve gentle for developers with experience in other ecosystems.
45+
Then use one of the helpers below:
3646

37-
### Play Links
38-
Every function includes a "Play" link to the Go Playground, allowing developers to quickly experiment and understand behavior without setting up a local environment.
47+
```go
48+
names := lo.Uniq([]string{"Samuel", "John", "Samuel"})
49+
// []string{"Samuel", "John"}
50+
```
3951

40-
### Variadic Functions
41-
Many functions accept variadic parameters (like `Keys()` accepting multiple maps), providing flexibility while maintaining type safety.
52+
### Tips for lazy developers
4253

43-
### Slice Type Parameters
44-
Functions use `~[]T` constraints to accept any slice type, including named slice types, not just `[]T`. This design choice makes the library more flexible in real-world usage.
54+
I cannot recommend it, but in case you are too lazy for repeating lo. everywhere, you can import the entire library into the namespace.
4555

46-
## The Name "lo"
56+
```go
57+
import (
58+
. "github.com/samber/lo"
59+
)
60+
```
4761

48-
The name was chosen to be short and memorable, similar to "Lodash". It's easy to type and no existing Go package was using this name, making it unique in the ecosystem.
62+
I take no responsibility for this junk. 😁 💩
4963

5064
## Community and Evolution
5165

@@ -66,3 +80,20 @@ Use `lo` when you need to:
6680
- Process data in parallel or with lazy evaluation
6781

6882
For simple operations, Go's standard library may suffice. But when you find yourself writing nested loops or complex data manipulation logic, `lo` provides the abstractions you need.
83+
84+
## Design Philosophy
85+
86+
### 1. **Type Safety Through Generics**
87+
Every function in `lo` is built on Go 1.18+ generics, ensuring compile-time type safety without sacrificing flexibility. This eliminates runtime type assertions and reduces bugs.
88+
89+
### 2. **Immutable by Default**
90+
The main `lo` package follows functional programming principles by returning new collections rather than modifying existing ones. This predictability makes code easier to reason about and test.
91+
92+
### 3. **Performance When Needed**
93+
For performance-critical scenarios, `lo` offers specialized packages:
94+
- `lo/mutable`: In-place operations that modify collections directly
95+
- `lo/parallel`: Concurrent processing with built-in worker pools
96+
- `lo/it`: Lazy evaluation using Go 1.23+ iterators
97+
98+
### 4. **Minimal Dependencies**
99+
`lo` has zero dependencies outside the Go standard library. This choice ensures reliability, security, and avoids dependency hell.

docs/docs/contributing.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: 🤝 Contributing
3+
description: Join the community of contributors.
4+
sidebar_position: 110
5+
---
6+
7+
# 🤝 Contributing
8+
9+
Hey! We are happy to have you as a new contributor. ✌️
10+
11+
For your first contribution please follow some guidelines:
12+
13+
## Function Naming
14+
Function naming: helpers must be self-explanatory and respect standards (other languages, libraries...). Feel free to suggest many names in your contributions.
15+
16+
## Variadic functions
17+
Many functions accept variadic parameters (like `lo.Keys(...map[K]V)` accepting multiple maps), providing flexibility while maintaining type safety.
18+
19+
## Slice type Parameters
20+
Functions use `~[]T` constraints to accept any slice type, including named slice types, not just `[]T`. This design choice makes the library more flexible in real-world usage.
21+
22+
## Variants
23+
When applicable, some functions can be added to sub-package as well: `mutable`, `it` and `parallel`. Add a documentation for each helper.
24+
25+
## Testing
26+
We try to maintain code coverage above 90%.
27+
28+
## Benchmark and performance
29+
Write performant helpers and limit extra memory consumption. Build an helper for general purpose and don't optimize for a particular use-case.
30+
31+
Feel free to write benchmarks.
32+
33+
Iterators can be unbounded and run for a very long time. If you expect a big memory footprint, please warn developers in the function comment.
34+
35+
## Documentation
36+
Functions must be properly commented, with a Go Playground link. New helpers must be created with a markdown documentation in `docs/data/`. In markdown header, please link to similar helpers (and update other markdowns accordingly).
37+
38+
## Examples
39+
Every function includes a "Play" link to the Go Playground, allowing developers to quickly experiment and understand behavior without setting up a local environment.
40+
41+
Please add an example of your helper in the file named `xxxx_example_test.go`. It will be available from Godoc website: https://pkg.go.dev/github.com/samber/lo

docs/docs/getting-started.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ sidebar_position: 1
1111
## Installation
1212

1313
```bash
14-
go get -u github.com/samber/lo
14+
go get -u github.com/samber/lo@v1
1515
```
1616

1717
## Base Package (`lo`)
@@ -40,8 +40,10 @@ import (
4040
loit "github.com/samber/lo/it"
4141
)
4242

43+
seqIn := iter.Range(0, 1000)
44+
4345
// Lazy iteration without buffering
44-
seq := loit.Filter(iter.Range(0, 1000), func(x int) bool {
46+
seqOut := loit.Filter(seqIn, func(x int) bool {
4547
return x%2 == 0
4648
})
4749
```
@@ -82,6 +84,7 @@ results := lop.Map(numbers, 4, func(x int) int {
8284
- **Performance** optimized with parallel and mutable variants
8385
- **Comprehensive** with 500+ utility functions
8486
- **Lazy evaluation** with `iter` std package (Go >= 1.23)
87+
- **Minimal dependencies** zero dependencies outside the Go standard library
8588

8689
## Next Steps
8790

563 KB
Loading

0 commit comments

Comments
 (0)