๐ค Contributing to LazyGophers Log
We welcome your contributions! We want to make contributing to LazyGophers Log as simple and transparent as possible, whether it's:
- ๐ Reporting a bug
- ๐ฌ Discussing the current state of the code
- โจ Submitting a feature request
- ๐ง Proposing a fix
- ๐ Implementing new features
๐ Table of Contents
๐ Code of Conduct
This project and all participants are governed by our Code of Conduct. By participating, you agree to abide by this code.
๐ Development Process
We use GitHub to host code, track issues and feature requests, and accept pull requests.
Workflow
- Fork the repository
- Clone your fork locally
- Create a feature branch from
master
- Make your changes
- Test thoroughly under all build tags
- Submit a pull request
๐ Getting Started
Prerequisites
Local Development Setup
# 1. Fork the repository on GitHub
# 2. Clone your fork
git clone https://github.com/YOUR_USERNAME/log.git
cd log
# 3. Add upstream remote
git remote add upstream https://github.com/lazygophers/log.git
# 4. Install dependencies
go mod tidy
# 5. Verify installation
make test-quick
Environment Setup
# Set Go environment (if not already set)
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
# Optional: Install useful tools
go install golang.org/x/tools/cmd/goimports@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
๐จ Pull Request Process
Before Submitting
- Search for existing PRs to avoid duplicates
- Test your changes under all build configurations
- Document any breaking changes
- Update related documentation
- Add tests for new features
PR Checklist
Submitting
- Push your changes to your fork
- Create a pull request to the
master branch
- Fill out the PR template completely
- Link any related issues
๐ป Coding Standards
General Guidelines
- Follow Go best practices: Effective Go
- Use meaningful variable and function names
- Keep functions small and focused
- Write self-documenting code
Specific Standards
- Code Style: Use
gofmt and goimports for formatting
- Error Handling: Use proper error wrapping and context
- Logging: Use the project's logging package appropriately
- Concurrency: Follow Go concurrency patterns safely
Build Tags
Some features may be conditionally compiled using build tags:
dev: Development features
test: Testing utilities
bench: Benchmarking tools
๐งช Testing Guidelines
Running Tests
# Run all tests
make test
# Run tests quickly (without race detection)
make test-quick
# Run tests with race detection
make test-race
# Run tests for a specific package
make test-pkg pkg=github.com/lazygophers/log
Writing Tests
- Write unit tests for all new functionality
- Use table-driven tests for multiple test cases
- Follow the existing test patterns
- Test both success and failure cases
Coverage
# Generate test coverage
make test-coverage
# View coverage report
make test-coverage-view
๐ท๏ธ Build Tag Requirements
When adding features that should be conditionally compiled:
- Use descriptive build tag names
- Document build tags in the README
- Ensure backward compatibility
- Test with and without the build tag
๐ Documentation
API Documentation
Update GoDoc comments for any public API changes:
// LogLevel represents the severity level of a log message
// Example:
// logger.SetLevel(log.InfoLevel)
type LogLevel int
User Documentation
Update the appropriate documentation files for:
- New features
- API changes
- Configuration options
- Usage examples
โ Issue Guidelines
Reporting Bugs
When reporting bugs, please include:
- Go version: Output of
go version
- Package version: Which version of the package you're using
- Description: A clear and concise description of the bug
- Steps to reproduce: Minimum steps to reproduce the issue
- Expected behavior: What you expected to happen
- Actual behavior: What actually happened
- Logs: Any relevant log output
- Code example: Minimal, complete, and verifiable example
Feature Requests
When requesting features, please include:
- Description: A clear and concise description of the feature
- Use case: Why this feature would be useful
- Proposal: A suggested implementation (optional)
- Alternatives: Any alternative solutions you've considered
โก Performance Considerations
- Benchmark: Add benchmarks for performance-sensitive code
- Profile: Use Go's profiling tools to identify bottlenecks
- Optimize: Focus on hot paths and critical sections
- Document: Note any performance considerations in the code
๐ Security Guidelines
If you discover a security vulnerability, please follow our Security Policy to report it responsibly.
- GitHub Discussions: For questions and discussions
- Issue Tracker: For bug reports and feature requests
- Slack: Join our community Slack channel
๐ License
By contributing to LazyGophers Log, you agree that your contributions will be licensed under the MIT License.
๐ Multilingual Documentation
This document is available in multiple languages: