Prompt
Maintain proper package organization by following established structural patterns and separation of concerns. Code should be organized into appropriate packages based on functionality and responsibility.
Key organizational principles:
- Module placement: Business logic modules belong in
pkg/modules/, not inintegrations/or other generic folders - Type definitions: Data structures and domain types should be placed in
pkg/types/with appropriate sub-packages (e.g.,cachetypes,quickfiltertypes) - Interface separation: Follow the three-package rule - interface declarations, implementations, and mocks must be in separate packages to avoid circular dependencies
- Constructor patterns: Complex object creation logic should be encapsulated in
Newfunctions within the types package - Visibility control: Only export types and functions that need to be used outside the package
Example of proper organization:
// pkg/types/tracefunnel/tracefunnel.go - Type definitions
type Funnel struct { ... }
// pkg/modules/tracefunnel/module.go - Interface declaration
type Module interface { ... }
// pkg/modules/tracefunnel/impltracefunnel/module.go - Implementation
type module struct { ... }
// pkg/modules/tracefunnel/tracefunneltest/mocks.go - Test mocks
type MockModule struct { ... }
This organization improves code maintainability, prevents circular dependencies, and makes the codebase more navigable for developers.