Thank you for considering contributing to Go Policy Enforcer! 🎉 This guide helps you navigate the contribution process and ensures code consistency across the project.
- Code of Conduct
- How Can I Contribute?
- Reporting Bugs
- Suggesting Enhancements
- Contributing Code
- Development Setup
- Style Guidelines
- Coding Standards
- Testing
- Pull Request Process
- Acknowledgments
This project follows a Contributor Code of Conduct. By participating, you agree to abide by its terms.
When reporting a bug, please include:
- Description: A concise summary of the bug.
- Steps to Reproduce: Describe how to trigger the bug.
- Expected Behavior: What should happen?
- Screenshots or Logs: Attach relevant details.
- Environment: OS, Go version, and any other relevant information.
Please file bug reports in the GitHub Issues.
Enhancement requests are welcome! When suggesting improvements:
- Title: A clear and descriptive title.
- Description: A detailed explanation.
- Benefits: Explain the benefit to users or developers.
We appreciate code contributions! Follow these guidelines to help your code align with the library's standards.
-
Fork the repository by clicking the "Fork" button on the GitHub page.
-
Clone your forked repository:
git clone https://github.com/kmesiab/go-policy-enforcer.git cd go-policy-enforcer
-
Create a new branch:
git checkout -b feature/your-feature-name
-
Install dependencies: Ensure you have installed Go 1.16+ and that dependencies are managed by Go modules. Verify your Go version with:
go version
We follow idiomatic Go patterns. Key practices include:
- Formatting: Run
go fmt
on all code. - +Linting: Use
golangci-lint
for comprehensive static analysis:
# Install golangci-lint
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
# Run linting
golangci-lint run
- Naming: Use descriptive names for functions and variables; avoid
abbreviations unless widely understood (e.g.,
len
,fmt
). - Error Handling: Return explicit error values, and log errors with meaningful messages.
- Code Structure:
- Functions that operate on common data types (e.g., slices) should be designed to be reusable.
- Group related functions in a single file, and separate logical units into distinct files (e.g., operators, helpers).
- Documentation: Document all exported functions and types with Go-style comments.
We use Conventional Commits to keep history clean and searchable:
- Format:
<type>(scope): <description>
- Types: Use types like
feat
,fix
,refactor
,docs
,test
, andchore
. - Examples:
feat(policy): add deep equality operator
fix(operators): handle nil cases in deep equality
- Link Issues: Mention related issues (e.g.,
Fixes #15
).
Testing is crucial for this library, especially given its logical complexity. Adhere to the following:
-
Write Tests: All new code must be covered by tests, especially custom
-
operators and utility functions.
-
Use Table-Driven Tests: For testing functions with multiple cases
-
(e.g., operators), use table-driven tests for clarity.
-
Run Tests: Verify functionality with
go test ./...
:go test ./...
-
Test Coverage: Aim for high coverage, especially for critical logic
-
in policy evaluation and operator functions.
-
Run Tests:
go test ./...
-
Commit Changes:
git add . git commit -m "feat(policy): add deep equality operator"
-
Push to Your Fork:
git push origin feature/your-feature-name
-
Submit a Pull Request:
- Go to the original repository.
- Click "New Pull Request".
- Select your branch and submit.
-
Review and Update: Be responsive to feedback and make adjustments as necessary.
Thank you for considering contributing to the Go Policy Enforcer project. We value your time and effort.