Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cd23c07c7d |
@@ -10,8 +10,8 @@ shared documents and are not edited here.
|
|||||||
2. Run `make check`. It runs the tests and the linter in Docker, then the format
|
2. Run `make check`. It runs the tests and the linter in Docker, then the format
|
||||||
check. All three must pass with no findings.
|
check. All three must pass with no findings.
|
||||||
|
|
||||||
Never run `go test`, `golangci-lint` or `gofmt` directly. The `make` targets
|
Never run `go test`, `golangci-lint` or `gofmt` directly. The scripts in
|
||||||
hold the flags and the Docker setup.
|
`script/` hold the flags and the Docker setup.
|
||||||
|
|
||||||
## Branches and pull requests
|
## Branches and pull requests
|
||||||
|
|
||||||
@@ -38,14 +38,14 @@ hold the flags and the Docker setup.
|
|||||||
|
|
||||||
## Architecture
|
## Architecture
|
||||||
|
|
||||||
- Dependency injection uses Uber `fx`. Every component is an `fx` provider,
|
- The server uses `go.uber.org/fx` for dependency injection. Each of its
|
||||||
wired together in `cmd/neoircd/main.go`.
|
components is an `fx` provider, wired together in `cmd/neoircd/main.go`.
|
||||||
- Application packages live under `internal/`, one package per concern.
|
- Application packages live under `internal/`, one package per concern.
|
||||||
`pkg/irc` holds the IRC command names and numeric reply codes.
|
`pkg/irc` holds the IRC command names and numeric reply codes.
|
||||||
- A handler method returns an `http.HandlerFunc`.
|
- A handler method returns an `http.HandlerFunc`.
|
||||||
- A request struct is defined inside the handler that decodes it.
|
- A request struct is defined inside the handler that decodes it.
|
||||||
- Database access goes through the methods of `db.Database`.
|
- Database access goes through the methods of `db.Database`.
|
||||||
- The database schema lives in `internal/db/schema/` and is embedded with
|
- The database migrations live in `internal/db/schema/` and are embedded with
|
||||||
`go:embed`.
|
`go:embed`.
|
||||||
- The database is SQLite, through the pure Go driver `modernc.org/sqlite`.
|
- The database is SQLite, through the pure Go driver `modernc.org/sqlite`.
|
||||||
|
|
||||||
@@ -54,11 +54,12 @@ hold the flags and the Docker setup.
|
|||||||
- Prefer table-driven tests.
|
- Prefer table-driven tests.
|
||||||
- Use `testing.T` helpers, not assertion libraries.
|
- Use `testing.T` helpers, not assertion libraries.
|
||||||
- A test file lives next to the code it tests and ends in `_test.go`.
|
- A test file lives next to the code it tests and ends in `_test.go`.
|
||||||
- Tests are in the package's external test package, such as `handlers_test`. An
|
- Tests are in the package's external test package, such as `handlers_test`.
|
||||||
`export_test.go` file in the package itself exposes what the tests need.
|
When a test needs an unexported name, an `export_test.go` file in the package
|
||||||
|
exposes it.
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
- The required libraries are listed in `CONVENTIONS.md` §1.
|
- The required libraries are listed in `CONVENTIONS.md` §1.
|
||||||
- No new dependency without a reason given in the pull request.
|
- No new dependency without a reason given in the pull request.
|
||||||
- Prefer pure Go. No cgo.
|
- Prefer dependencies written in pure Go, which build without cgo.
|
||||||
|
|||||||
Reference in New Issue
Block a user