Thank you for your interest in contributing to go-bindiff-struct! This document provides guidelines and instructions for contributing.
- Fork the repository
- Clone your fork:
git clone https://github.com/YOUR_USERNAME/go-bindiff-struct.git cd go-bindiff-struct - Add the upstream repository:
git remote add upstream https://github.com/BaseMax/go-bindiff-struct.git
- Go 1.21 or later
- Git
- Make (optional, but recommended)
# Using make
make build
# Or directly with go
go build -o bin/go-bindiff-struct ./cmd/go-bindiff-struct# Using make
make test
# Or directly with go
go test ./...# Format code
make fmt
# Or
go fmt ./...# Run go vet
make vet
# Or
go vet ./...-
Create a feature branch from
main:git checkout -b feature/your-feature-name
-
Make your changes
-
Commit with clear messages:
git commit -m "Add feature: description of what you added"
- Use present tense ("Add feature" not "Added feature")
- Use imperative mood ("Move cursor to..." not "Moves cursor to...")
- Limit the first line to 72 characters or less
- Reference issues and pull requests after the first line
Example:
Add support for WASM binary format
- Implement WASM parser
- Add WASM to default registry
- Update documentation
- Add tests for WASM parsing
Fixes #123
- Follow standard Go conventions
- Use
gofmtto format your code - Write clear, self-documenting code
- Add comments for exported functions and types
- Keep functions focused and concise
- Add tests for all new functionality
- Aim for high test coverage
- Use table-driven tests where appropriate
- Test both success and failure cases
Example:
func TestFeature(t *testing.T) {
tests := []struct {
name string
input string
expected string
}{
{"case1", "input1", "output1"},
{"case2", "input2", "output2"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := Feature(tt.input)
if result != tt.expected {
t.Errorf("got %s, want %s", result, tt.expected)
}
})
}
}# Run all tests
make test
# Run tests with coverage
make test-coverage
# Run specific package tests
go test ./parser -v- Create a new file in
parser/(e.g.,wasm.go) - Implement the
Parserinterface:type WASMParser struct{} func (p *WASMParser) CanParse(r io.ReaderAt) bool { ... } func (p *WASMParser) Parse(r io.ReaderAt, size int64) (*model.Binary, error) { ... } func (p *WASMParser) Format() model.BinaryFormat { ... }
- Register in
DefaultRegistry()inparser.go - Add tests in
parser_test.go - Update documentation
- Add the algorithm to
diff/engine.go - Update the
Diff()method to call your algorithm - Create appropriate
Changeentries - Add tests
- Update documentation
- Create a renderer in
render/renderer.go - Implement the
Rendererinterface - Add to CLI format handling in
cmd/go-bindiff-struct/main.go - Add to API in
api/client.go - Add tests
- Update documentation
- Update README.md for user-facing changes
- Update API.md for library API changes
- Update ARCHITECTURE.md for architectural changes
- Add examples for new features
- Use clear, concise language
- Include code examples
- Update documentation
- Add tests for new functionality
- Ensure all tests pass
- Update CHANGELOG.md (if present)
- Push to your fork
- Create a pull request
- Provide a clear description of the changes
- Reference related issues
- Include screenshots for UI changes (if applicable)
- Keep PRs focused on a single concern
- Respond to review comments promptly
## Description
Brief description of what this PR does
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
How has this been tested?
## Checklist
- [ ] Code follows project style guidelines
- [ ] Tests added/updated
- [ ] Documentation updated
- [ ] All tests passAll submissions require review. We use GitHub pull requests for this purpose.
Reviewers will check for:
- Code quality and style
- Test coverage
- Documentation
- Performance implications
- Security considerations
If you discover a security vulnerability, please email the maintainer directly rather than opening a public issue.
By contributing, you agree that your contributions will be licensed under the MIT License.
Feel free to open an issue for questions or discussions about contributing.
Contributors will be acknowledged in the project README and release notes.
Thank you for contributing to go-bindiff-struct!