Thank you for your interest in contributing to Cozeloop! This document provides guidelines for contributing to the project, covering contribution methods, project overview, development environment setup, code submission process, coding style and conventions, testing requirements, documentation requirements, and CI/CD processes.
You can contribute to the Cozeloop project in several ways:
- Submit and vote for new feature ideas
- Create and comment on issues
- Submit pull requests
- Improve documentation and code comments
- Participate in code reviews
Improvements to the core application, and documentation are all welcome. If you have any questions, please contact the project maintainers.
Before making significant changes, please open an issue to discuss your proposed changes. Make sure tests pass before submitting a pull request.
You could go to README to find more information.
Detailed Submission Process (Click to expand)
-
Create a feature branch from the
mainbranch:git checkout main git pull git checkout -b feat/your-feature-name
-
Develop and commit on the feature branch
-
Ensure the code passes all tests:
cd ./backend && go test -gcflags="all=-N -l" ./...
-
Push the branch to the remote repository:
git push origin feat/your-feature-name
-
Create a Pull Request to the
mainbranch -
After code review is passed, merge into the
mainbranch
graph TD
A[Start] --> B[Fork Repository]
B --> C[Create Feature Branch]
C --> D[Develop and Test]
D --> E[Commit Changes]
E --> F[Push to Remote]
F --> G[Create Pull Request]
G --> H[Code Review]
H --> I{Review Passed?}
I -- Yes --> J[Merge to Main Branch]
I -- No --> D
J --> K[End]
Follow the Conventional Commits best practices:
<type>[optional scope]: <description>
[optional body]
[optional footer]
Types include:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Changes that do not affect code meaning (whitespace, formatting, etc.)refactor: Code changes that neither fix a bug nor add a featureperf: Code changes that improve performancetest: Adding or correcting testschore: Changes to the build process or auxiliary tools
Example:
feat(api): add user authentication interface
Implement JWT-based user authentication mechanism, including login, logout, and token refresh functionality.
Closes #123
- Follow recommendations in Effective Go and Go Code Review Comments
- Use
gofmtorgoimportsto format code - Use
golintandgo vetto check code quality - Package names should be short, clear, all lowercase, with no underscores or mixed case
- File names should be all lowercase, with words separated by underscores
- API paths follow RESTful design principles
- Error handling uses the
errornpackage in the project - Dependency injection uses the
wirepackage - Database operations use the
gormpackage
- Business logic code goes in the
modulesdirectory, organized by functional modules - Common utilities and helper functions go in the
pkgdirectory - API definitions and handlers go in the
apidirectory - Infrastructure code (database, cache, etc.) goes in the
infradirectory - Follow the principle of Domain-Driven Design
- All public functions and methods should have unit tests
- Test files should be placed in the same directory as the code being tested, named
xxx_test.go - Use the Go standard library's
testingpackage to write tests - Use table-driven testing methods to handle multiple test cases
- It is better to Use mockgen to generate mock struct instead of using patch
Run unit tests:
cd ./backend && go test -gcflags="all=-N -l" ./...- All exported functions, methods, types, and constants should better have comments
- Comments should start with the name of the item being documented and be complete sentences
- Use GoDoc format for writing comments
Example:
// UserService provides operations related to users.
type UserService struct {
// ...
}
// Create creates a new user and returns the user ID.
// If the user already exists, it returns ErrUserAlreadyExists.
func (s *UserService) Create(ctx context.Context, user *User) (int64, error) {
// ...
}The project uses a CI system for automated testing and building. Each Pull Request triggers the following checks:
- Unit tests
- Integration tests
- Build check
Cozeloop is licensed under the Apache 2.0 License. By submitting code to the project, you agree that your contributions will be available under this license.
Before your contribution can be accepted, you need to agree that:
- You have the right to submit the contribution under the Apache 2.0 license
- The contribution is your original work or you have the right to submit it
- You grant the project maintainers the right to distribute your contribution under the project's license
For questions, discussions, or assistance, please use the following channels:
- GitHub Issues: For bug reports and feature requests
- GitHub Discussions: For general questions and discussions
If you have questions or need help, please contact the project maintainers.
Thank you for contributing to the Cozeloop project!