# Conventions of TiDB Operator

Conventions are copied from [Kubernetes Conventions](https://www.kubernetes.dev/docs/guide/coding-convention), with some unused items removed.

## Code conventions

- [Bash Sytle Guide](https://google.github.io/styleguide/shellguide.html)
- [Effective Go](https://go.dev/doc/effective_go)
- [Go Code Review Comments](https://go.dev/wiki/CodeReviewComments)
- [Go Test Comments](https://go.dev/wiki/TestComments)
- [Go Style Guide](https://google.github.io/styleguide/go/decisions)
- [Kubernetes API Conventions](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md)

## Directory and file conventions

- Avoid package sprawl. Find an appropriate subdirectory for new packages.
- Avoid general utility packages. Packages called "util" are suspect. Instead, derive a name that describes your desired function. For example, the utility functions dealing with waiting for operations are in the wait package and include functionality like Poll. The full name is wait.Poll.
- All filenames should be lowercase.
- Go source files and directories use underscores, not dashes.
- Package directories should generally avoid using separators as much as possible. When package names are multiple words, they usually should be in nested subdirectories.
- Document directories and filenames should use dashes rather than underscores.
- Forked third party Go code goes in third_party.
- Third-party code must include licenses. This includes modified third-party code and excerpts, as well.

