Debian Codegraph @

CONTRIBUTING.md

raw
1 # Contributing
2
3 ## How to contribute
4
5 We definitely welcome patches and contribution to this project!
6
7 In particular we would love feedback and contributions from anyone with real
8 world experience using this project, and would love help with adding assembly
9 implementations of IndexByte, CountByte, and IndexNonASCII for processor
10 architectures (GOARCH) that we don't already have asm implementations for (a
11 review of the current amd64 and arm64 implementations by someone who actually
12 knows these architectures would also be welcome).
13
14 ## Discuss Significant Changes
15
16 Before you invest a significant amount of time on a change, please create a
17 discussion or issue describing your proposal. This will help to ensure your
18 proposed change has a reasonable chance of being merged.
19
20 ## Avoid Dependencies
21
22 Adding a dependency is a big deal. While on occasion a new dependency may be
23 accepted, the default answer to any change that adds a dependency is no.
24
25 ## Avoid Allocating
26
27 Allocating memory is never allowed unless the corresponding function in
28 the [strings](https://pkg.go.dev/strings) package also allocates memory
29 or if the change was previously discussed and provides a speedup that
30 justifies the allocation.
31
32 ## Development Environment Setup
33
34 Run `make pre-commit` to install a git pre-commit hook that checks if either
35 [internal/gen/gentables/main.go](./internal/gen/gentables/main.go) or
36 [.tables.json](./.tables.json) are out of date. Any change to
37 `internal/gen/gentables` requires the code generation to be re-run (`go
38 generate`) and the resulting changes to `.tables.json` to be committed along
39 side any changes to `internal/gen/gentables`. The `.tables.json` stores a hash
40 of the `internal/gen/gentables` Go files so that we don't accidentally change
41 hash table generation logic without also re-running the generation code (this
42 may change in a future release since re-generating the hash tables is slow).
43
44 The `testgenerate` make target can be used to check if `go generate` needs to
45 be ran.
46
47 **NOTE:** The [gen.go](./gen.go) is a wrapper that can be used to run the
48 generation code for all supported Unicode version and is what the Makefile
49 uses. It exists because `internal/gen` is a separate module and it handles
50 the building of the generate binary. This was done to prevent the separate
51 the generate dependencies from the strcase dependencies.
52
53 ## Running Tests
54
55 Before submitting a PR run the `release` make target (`make release`).
56 This will run all the tests, perform a more exhaustive fuzz test, and
57 lint the code.
58
59 During development running `go test` is generally sufficient.
60
61 If working on the generation code the [internal/gen/Makefile](./internal/gen/Makefile)
62 can be used.
63
64 ## Running Benchmarks
65
66 The [internal/benchtest](./internal/benchtest) directory contains the release
67 benchmarks that are used to compare strcase to the strings package see the
68 packages [README](./internal/benchtest/README.md) for more information. But
69 TLDR `make release` can be ran from that directory to generate a statistically
70 accurate comparison (note: it is very slow).
71
72 Any strcase specific benchmarks should be added to
73 [`strcase_test.go`](./strcase_test.go).