Thank you for your interest in contributing to the Trusera Go SDK!
- Go 1.21 or higher
- Git
-
Fork the repository
-
Clone your fork:
git clone https://github.com/YOUR_USERNAME/trusera-sdk-go.git cd trusera-sdk-go -
Install dependencies:
go mod download
-
Run tests:
go test -v ./...
# Run all tests
go test ./...
# Run tests with coverage
go test -cover ./...
# Run tests with race detection
go test -race ./...
# Run specific test
go test -run TestName ./...We use golangci-lint for linting. Install it:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latestRun linting:
golangci-lint run- Follow standard Go conventions and idioms
- Use
gofmtto format code (automatically done by most editors) - Write clear, concise comments for exported functions
- Keep functions focused and small
- Prefer composition over complexity
feature/description- New featuresfix/description- Bug fixesdocs/description- Documentation updatestest/description- Test additions or improvements
Follow conventional commits format:
type(scope): brief description
Detailed explanation if needed.
Fixes #issue-number
Types:
feat: New featurefix: Bug fixdocs: Documentation changestest: Test additions/changesrefactor: Code refactoringperf: Performance improvementschore: Build process or auxiliary tool changes
Examples:
feat(interceptor): add request timeout enforcement
fix(client): prevent race condition in event queue
docs(readme): add examples for block mode
- Update tests for any new functionality
- Ensure all tests pass:
go test ./... - Run linting:
golangci-lint run - Update documentation if needed
- Update CHANGELOG.md with your changes
- Create a pull request with a clear description
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
How have you tested this?
## Checklist
- [ ] Tests pass
- [ ] Linting passes
- [ ] Documentation updated
- [ ] CHANGELOG.md updatedtrusera-sdk-go/
├── trusera.go # Main client implementation
├── events.go # Event types and creation
├── interceptor.go # HTTP interception logic
├── *_test.go # Test files
├── examples/ # Example programs
│ ├── basic/
│ ├── http-interceptor/
│ └── block-mode/
├── .github/
│ └── workflows/
│ └── ci.yml # CI/CD configuration
└── README.md
- Use table-driven tests where appropriate
- Test both success and failure cases
- Use
httptestfor HTTP-related tests - Ensure thread safety in concurrent tests
- Mock external dependencies
Example:
func TestFeature(t *testing.T) {
tests := []struct {
name string
input string
want string
wantErr bool
}{
{"valid input", "test", "result", false},
{"invalid input", "", "", true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := Feature(tt.input)
if (err != nil) != tt.wantErr {
t.Errorf("error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("got %v, want %v", got, tt.want)
}
})
}
}- Maintain at least 80% test coverage
- Critical paths should have 100% coverage
- Test edge cases and error conditions
- All exported functions, types, and constants must have comments
- Comments should explain "why", not just "what"
- Use complete sentences with proper punctuation
Example:
// Client sends agent events to Trusera API for monitoring and compliance.
// It handles batching, retries, and background flushing automatically.
type Client struct {
// ...
}
// NewClient creates a Trusera monitoring client with the given API key.
// Use functional options to customize behavior.
func NewClient(apiKey string, opts ...Option) *Client {
// ...
}Update README.md when:
- Adding new features
- Changing API behavior
- Adding new configuration options
- Update version in relevant files
- Update CHANGELOG.md with release notes
- Create git tag:
git tag v1.0.0 - Push tag:
git push origin v1.0.0 - GitHub Actions will handle the release
This SDK uses only the Go standard library. Adding external dependencies requires strong justification and discussion in an issue first.
- Open an issue for bugs or feature requests
- Join our Discord community
- Email: opensource@trusera.io
Be respectful, inclusive, and professional. See CODE_OF_CONDUCT.md.
By contributing, you agree that your contributions will be licensed under the Apache 2.0 License.