- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests and linting
- Submit a pull request
Conventional Commits:
type(scope): description
| Type | Purpose |
|---|---|
feat |
New feature |
fix |
Bug fix |
docs |
Documentation changes |
test |
Adding or updating tests |
refactor |
Code refactoring (no behavior change) |
chore |
Build, tooling, dependency updates |
| Scope | Area |
|---|---|
http |
HTTP handlers, routes, middleware |
sqlite |
SQLite persistence layer |
cli |
Command-line interface |
api |
API contracts, endpoints |
domain |
Business logic, entities |
sse |
Server-Sent Events |
feat(http): add bulk log endpoint
fix(sqlite): handle database locked errors
docs: update API endpoint documentation
test(domain): add table-driven tests for log validation
refactor(persistence): extract retry logic to helper
chore: upgrade go.mod dependenciesBefore submitting a PR:
# Run all tests
go test ./...
# Run with coverage
go test -cover ./...- Domain layer: Unit tests for all business logic
- HTTP handlers: Integration tests with mocked repos
- SQLite repositories: Integration tests with test database
- Concurrent operations: Test with 10+ simultaneous requests
- Edge cases: Empty inputs, nil values, boundary conditions
# Full test suite
make test
# Or manually
go test -v -race ./internal/...# Format code
gofmt -w .
# Lint (if golangci-lint installed)
golangci-lint run
# Build check
go build ./...All dependencies must be injected:
// Bad
var db *sql.DB
func handler() {
db.Query(...)
}
// Good
func handler(db *sql.DB) {
db.Query(...)
}Use interface injection for repositories:
type HostHandler struct {
repo domain.HostRepository
}
func NewHostHandler(repo domain.HostRepository) *HostHandler {
return &HostHandler{repo: repo}
}All database and HTTP operations must accept context:
func (r *LogRepository) Create(ctx context.Context, log *entities.Log) error {
_, err := r.db.ExecContext(ctx, "INSERT INTO logs ...")
return err
}
func (h *LogHandler) CreateLog(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
// Use ctx for all downstream operations
}Use structured logging, not fmt.Printf:
import "log/slog"
// Good
slog.Info("log created", "id", log.ID, "level", log.Level)
// Bad
fmt.Printf("log created: %v\n", log)- Always check errors
- Wrap errors with context:
fmt.Errorf("failed to save host: %w", err) - Return errors from handlers, don't panic
- Update documentation if needed
- Ensure all tests pass
- Update CHANGELOG.md (if applicable)
- Your PR will be reviewed and may require changes
- Once approved, maintainers will merge
Open an issue or comment on an existing PR.