This repository demonstrates the application of the Composite design pattern in Go. The project highlights the implementation of composite structures, allowing individual objects and compositions of objects to be treated uniformly. This pattern is ideal for representing part-whole hierarchies in a system.
The Composite pattern is used to compose objects into tree structures to represent part-whole hierarchies. It lets clients treat individual objects and compositions of objects uniformly. In this project, we have implemented both Leaf and Composite components to demonstrate this pattern effectively.
- cmd/: Contains the application entry point (
main.go
), demonstrating the creation and manipulation of the composite structure. - pkg/
- composite/: Houses the component interfaces and their implementations (
Leaf
andComposite
).
- composite/: Houses the component interfaces and their implementations (
This project features the management of components within a composite structure. It includes functionality for adding, removing, displaying, and counting components, showcasing the flexibility and power of the Composite pattern.
Ensure you have Go installed on your system. You can download it from Go's official site.
Clone this repository to your local machine:
git clone https://github.com/arthurfp/Go_Composite_Pattern.git
cd Go_Composite_Pattern
To run the application, execute:
go run cmd/main.go
To execute the tests and verify the functionality:
go test ./...
Contributions are welcome! Please feel free to submit pull requests or open issues to discuss proposed changes or enhancements.
Arthur Ferreira - github.com/arthurfp