|
1 | | -# Contributing to `list` |
| 1 | +# Contributing |
2 | 2 |
|
3 | | -Thanks for your interest in contributing. This guide covers the operational process. For the **why** — the design principles every contribution is tested against — see **[bold-minds/oss/PRINCIPLES.md](https://github.com/bold-minds/oss/blob/main/PRINCIPLES.md)**. |
| 3 | +Thank you for your interest in contributing! We welcome contributions that improve the library while maintaining its focus on simplicity, performance, and Go idioms. |
4 | 4 |
|
5 | | -## 🎯 Before You Start |
| 5 | +## Getting Started |
6 | 6 |
|
7 | | -Every contribution is measured against the four Bold Minds principles: **outcome naming**, **one way to do each thing**, **get out of the way**, and **non-goals explicit**. If your proposed change doesn't honor these, it will not be merged. |
| 7 | +### Prerequisites |
8 | 8 |
|
9 | | -**Read [PRINCIPLES.md](https://github.com/bold-minds/oss/blob/main/PRINCIPLES.md) first.** It's the load-bearing document. |
| 9 | +- **Go 1.22+** |
| 10 | +- **Git** |
| 11 | +- **golangci-lint** (optional, for comprehensive linting) |
10 | 12 |
|
11 | | -## 🔧 Development Setup |
| 13 | +### Development Setup |
12 | 14 |
|
13 | | -**Requirements:** Go 1.23 or later, Git, Bash. |
| 15 | +1. **Fork and clone the repository**: |
| 16 | + ```bash |
| 17 | + git clone https://github.com/YOUR_USERNAME/list.git |
| 18 | + cd list |
| 19 | + ``` |
14 | 20 |
|
15 | | -```bash |
16 | | -git clone https://github.com/bold-minds/list.git |
17 | | -cd list |
18 | | -go test ./... # unit tests |
19 | | -go test -race ./... # race detection |
20 | | -go test -bench=. ./... # benchmarks |
21 | | -./scripts/validate.sh # full validation pipeline (local mode) |
22 | | -./scripts/validate.sh ci # strict CI mode |
23 | | -``` |
| 21 | +2. **Run tests**: |
| 22 | + ```bash |
| 23 | + go test -race ./... |
| 24 | + ``` |
24 | 25 |
|
25 | | -Your contribution must pass `./scripts/validate.sh ci` before submitting. |
| 26 | +## What We're Looking For |
26 | 27 |
|
27 | | -## 📁 Project Structure |
| 28 | +### Encouraged |
28 | 29 |
|
29 | | -``` |
30 | | -list/ |
31 | | -├── list.go # Implementation (single file) |
32 | | -├── list_test.go # Unit tests |
33 | | -├── bench_test.go # Benchmarks |
34 | | -├── examples/ # Runnable examples |
35 | | -├── scripts/ |
36 | | -│ └── validate.sh # Validation pipeline |
37 | | -├── README.md |
38 | | -├── CONTRIBUTING.md # This file |
39 | | -├── CHANGELOG.md |
40 | | -├── CODE_OF_CONDUCT.md |
41 | | -├── SECURITY.md |
42 | | -├── LICENSE |
43 | | -└── go.mod |
44 | | -``` |
| 30 | +- **Bug fixes** — fix issues or edge cases |
| 31 | +- **Performance improvements** — optimize without breaking compatibility |
| 32 | +- **Test enhancements** — add test cases, improve coverage |
| 33 | +- **Documentation improvements** — clarify usage, add examples |
45 | 34 |
|
46 | | -Flat layout. No `internal/` directory. |
| 35 | +### Requires Discussion First |
47 | 36 |
|
48 | | -## 🎨 Code Style |
| 37 | +- **API changes** — modifications to public interfaces |
| 38 | +- **New dependencies** — adding external packages |
| 39 | +- **Breaking changes** — changes that affect backward compatibility |
49 | 40 |
|
50 | | -### Naming |
51 | | -- Outcome naming per PRINCIPLES.md. Function names describe the set operation performed (`Unique`, `Union`, `Intersect`, `Minus`, `Without`). |
| 41 | +### Not Accepted |
52 | 42 |
|
53 | | -### Error Handling |
54 | | -- Functions **must not panic** on valid input (nil, empty, or otherwise). |
55 | | -- No error returns — set operations either succeed or return empty slices. |
56 | | -- Never `Must*` variants. |
| 43 | +- **Feature creep** — complex features that don't align with Go idioms |
| 44 | +- **Non-idiomatic Go** — code that doesn't follow Go conventions |
| 45 | +- **Performance regressions** — changes that significantly slow down the library |
57 | 46 |
|
58 | | -### Documentation |
59 | | -- Every exported function has a doc comment. |
60 | | -- Edge cases (nil, empty, NaN, aliasing, immutability) documented in the package doc and README. |
| 47 | +## Contribution Process |
61 | 48 |
|
62 | | -### Dependencies |
63 | | -- **Zero external dependencies.** `list` is pure stdlib. |
| 49 | +### 1. Create an Issue First |
64 | 50 |
|
65 | | -## 🧪 Testing |
| 51 | +For significant changes, please create an issue to discuss: |
| 52 | +- What problem you're solving |
| 53 | +- Your proposed approach |
| 54 | +- Any potential breaking changes |
66 | 55 |
|
67 | | -**Coverage target: 100% of exported functions.** |
| 56 | +### 2. Development Workflow |
68 | 57 |
|
69 | | -```bash |
70 | | -go test -v ./... |
71 | | -go test -race ./... |
72 | | -go test -cover ./... |
73 | | -go test -bench=. -benchmem ./... |
74 | | -``` |
| 58 | +1. **Create a feature branch**: |
| 59 | + ```bash |
| 60 | + git checkout -b feature/your-feature-name |
| 61 | + ``` |
75 | 62 |
|
76 | | -**Every PR must include adversarial tests.** In addition to happy-path coverage, tests must verify: |
| 63 | +2. **Make your changes** — follow the code style guidelines below, add tests, update documentation as needed. |
77 | 64 |
|
78 | | -1. **Non-nil empty returns** — no function returns nil for empty or missing results. |
79 | | -2. **Immutability** — the input slice is byte-identical before and after the call. |
80 | | -3. **Result aliasing** — mutating the returned slice must not affect the input. |
81 | | -4. **NaN semantics** (for float-aware features) — behavior is consistent with Go's map-key rules. |
82 | | -5. **Custom comparable types** — named types (`type UserID string`) and struct keys work correctly. |
| 65 | +3. **Validate your changes**: |
| 66 | + ```bash |
| 67 | + go fmt ./... |
| 68 | + go vet ./... |
| 69 | + go test -race ./... |
| 70 | + ``` |
83 | 71 |
|
84 | | -## 📝 Pull Request Process |
| 72 | +4. **Commit your changes**: |
| 73 | + ```bash |
| 74 | + git commit -m "feat: add your feature description" |
| 75 | + ``` |
85 | 76 |
|
86 | | -### PR Checklist |
| 77 | +5. **Push and create a pull request**: |
| 78 | + ```bash |
| 79 | + git push origin feature/your-feature-name |
| 80 | + ``` |
87 | 81 |
|
88 | | -- [ ] **Outcome naming** — does the function name describe what the caller gets? |
89 | | -- [ ] **One way** — does any existing function already do this? |
90 | | -- [ ] **Get out of the way** — can a Go dev use this from the signature alone? |
91 | | -- [ ] **Non-goals** — does this violate any of the library's stated non-goals? |
92 | | -- [ ] Tests cover 100% of new code |
93 | | -- [ ] Adversarial tests included (nil, immutability, aliasing, NaN where applicable) |
94 | | -- [ ] Benchmarks added for new exported functions |
95 | | -- [ ] README updated |
96 | | -- [ ] CHANGELOG.md updated |
97 | | -- [ ] `./scripts/validate.sh ci` passes locally |
| 82 | +### 3. Pull Request Guidelines |
98 | 83 |
|
99 | | -## 🆕 Adding a New Function |
| 84 | +Your PR should: |
| 85 | +- Have a clear title describing the change |
| 86 | +- Reference any related issues using `Fixes #123` or `Closes #123` |
| 87 | +- Include tests for new functionality |
| 88 | +- Pass all CI checks |
| 89 | +- Maintain backward compatibility unless discussed otherwise |
100 | 90 |
|
101 | | -`list` is deliberately tiny (five functions). New additions must clear a high bar: |
| 91 | +## Code Style |
102 | 92 |
|
103 | | -1. Read the library's non-goals in [README.md](README.md) and [PRINCIPLES.md](https://github.com/bold-minds/oss/blob/main/PRINCIPLES.md). |
104 | | -2. Prove the stdlib gap. Current Go's `slices` package is more capable than many people realize. |
105 | | -3. Show real-world evidence of the pain. |
106 | | -4. If the function operates on maps or uses a predicate, it belongs in a different library (`each` for predicates, `stdlib maps` for maps). |
| 93 | +- Follow standard Go formatting (`go fmt`) |
| 94 | +- Use meaningful variable and function names |
| 95 | +- Write clear, concise comments for public APIs |
| 96 | +- Follow Go's error handling patterns |
| 97 | +- Write table-driven tests where appropriate |
| 98 | +- Test both success and error cases |
| 99 | +- Include edge cases (nil values, empty strings, etc.) |
| 100 | +- Run tests with `-race` to ensure thread safety |
107 | 101 |
|
108 | | -## 🏷️ Versioning and Releases |
| 102 | +## Commit Messages |
| 103 | + |
| 104 | +We follow conventional commits: |
| 105 | + |
| 106 | +``` |
| 107 | +type(scope): description |
| 108 | +``` |
109 | 109 |
|
110 | | -- Semantic versioning |
111 | | -- v0.x: API may change between minor versions |
112 | | -- v1.0+: breaking changes require major version bump |
113 | | -- Every release updates CHANGELOG.md |
| 110 | +Types: `feat`, `fix`, `docs`, `test`, `refactor`, `perf`, `chore` |
114 | 111 |
|
115 | | -## 🙏 Code of Conduct |
| 112 | +## Code Review |
116 | 113 |
|
117 | | -See [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md). |
| 114 | +We look for: correctness, performance, style, tests, documentation, and backward compatibility. Initial review within 2-3 business days. |
118 | 115 |
|
119 | | -## 📄 License |
| 116 | +## License |
120 | 117 |
|
121 | | -By contributing, you agree your contributions are licensed under the MIT License. |
| 118 | +By contributing, you agree that your contributions will be licensed under the same license that covers the project. |
0 commit comments