Thank you for your interest in contributing to go-openexr! This document provides guidelines and information for contributors.
This project follows the Linux Foundation Code of Conduct. By participating, you are expected to uphold this code.
| Requirement | Version |
|---|---|
| Go | 1.21 or later |
| Git | Any recent version |
# Fork and clone the repository
git clone https://github.com/YOUR_USERNAME/go-openexr.git
cd go-openexr
# Verify tests pass
go test ./...
# Run benchmarks
go test -bench=. ./...For testing with real EXR files, download test images from the openexr-images repository and place them in testdata/.
-
Create a feature branch from
main:git checkout -b feature/your-feature-name
-
Make your changes with clear, focused commits
-
Ensure all tests pass:
go test ./... go test -race ./... # Run with race detector
-
Push and create a pull request
This library follows several core principles that guide design decisions:
Caller validates, callee assumes. Public functions validate inputs at API boundaries and return meaningful errors. Internal methods and unexported functions assume they receive valid data. Do not add defensive nil checks to method receivers—a panic on nil dereference points directly to the bug; a silent fallback masks it.
// Good: Validate at the entry point
func NewScanlineReader(f *File) (*ScanlineReader, error) {
if f == nil {
return nil, ErrInvalidFile
}
// ... rest of function assumes f is valid
}
// Bad: Defensive check inside method
func (r *ScanlineReader) ReadRow() error {
if r == nil { // Don't do this
return nil
}
// ...
}Fail fast. Return errors for conditions callers can handle (malformed files, missing attributes). Let programmer errors (violated invariants, nil receivers) panic—the stack trace identifies the bug immediately.
Performance is a feature. This is an image processing library handling large data. Avoid per-call overhead in hot paths: no redundant validation, minimize allocations, prefer stack over heap. Validate once at boundaries, then trust the data internally.
Security through structured validation. Malformed inputs are caught by validation at parsing boundaries, not scattered defensive checks. Fuzz testing continuously probes edge cases. When fuzzing finds a crash, fix it with proper validation where the data enters the system.
Errors are for callers. Return errors when callers can reasonably act on them. Use specific error types or messages that help diagnose issues. Avoid generic errors like "invalid data"—say what's invalid and why.
- Follow standard Go conventions and idioms
- Run
gofmton all code - Add tests for new functionality
- Update documentation for API changes
- Prefer short, clear functions over deeply nested code
- Use meaningful variable and function names
- Prefer early returns over deep nesting
- Use clear, descriptive commit messages
- Start with a brief summary (50 chars or less)
- Include details in the body if needed
- Reference issues when applicable
Example:
Add support for deep tiled images
Implements reading and writing of deep tiled EXR files as specified
in the OpenEXR 2.0 format.
Fixes #123
- Write tests for all new functionality
- Ensure tests cover both success and error paths
- Use table-driven tests where appropriate
- Run tests with race detection before submitting
# Run all tests
go test ./...
# Run with race detection
go test -race ./...
# Run with coverage
go test -cover ./...
# Run benchmarks
go test -bench=. ./...- Update documentation for any API changes
- Add or update tests as needed
- Ensure all tests pass, including race detection
- Update the README.md if needed
- Request review from maintainers
| Criteria | Description |
|---|---|
| Correctness | Code works as intended with good test coverage |
| Go idioms | Follows standard Go conventions and patterns |
| Documentation | Clear comments and godoc for exported APIs |
| Performance | Considers allocations and hot paths |
| Compatibility | Maintains backward compatibility |
When reporting bugs, please include:
| Information | Example |
|---|---|
| Go version | Output of go version |
| OS / Architecture | macOS 14 / arm64, Ubuntu 22.04 / amd64 |
| Steps to reproduce | Minimal code or commands |
| Expected behavior | What should happen |
| Actual behavior | What actually happens |
| Sample file | Attach EXR file or describe how to generate |
For feature requests, please describe:
| Information | Description |
|---|---|
| Use case | Why you need this feature |
| Relation to existing | How it fits with current functionality |
| Implementation ideas | Any suggestions for how to implement |
- Add godoc comments to all exported functions, types, and constants
- Include examples in documentation where helpful
- Update the README for significant changes
This library aims to be performant for production use. When making changes:
- Consider memory allocations
- Use benchmarks to measure performance impact
- Profile code for hot paths
- Consider concurrent access patterns
Feel free to open an issue for questions about contributing.
By contributing to go-openexr, you agree that your contributions will be licensed under the Apache License 2.0.