{"id":23408504,"url":"https://github.com/arthurfp/go_command_pattern","last_synced_at":"2025-04-09T01:32:48.520Z","repository":{"id":269124558,"uuid":"906497938","full_name":"arthurfp/Go_Command_Pattern","owner":"arthurfp","description":"A Go project demonstrating the Command pattern by encapsulating requests as objects. This repository showcases best practices in design patterns, command execution, and unit testing.","archived":false,"fork":false,"pushed_at":"2024-12-21T04:56:49.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-14T19:51:52.206Z","etag":null,"topics":["code-pattern","command","command-pattern","go","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arthurfp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-21T04:27:33.000Z","updated_at":"2024-12-21T04:59:01.000Z","dependencies_parsed_at":"2024-12-21T05:25:33.557Z","dependency_job_id":"0a38b8ad-7d07-43d2-bf7f-b15591f8ac62","html_url":"https://github.com/arthurfp/Go_Command_Pattern","commit_stats":null,"previous_names":["arthurfp/go_command_pattern"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arthurfp%2FGo_Command_Pattern","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arthurfp%2FGo_Command_Pattern/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arthurfp%2FGo_Command_Pattern/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arthurfp%2FGo_Command_Pattern/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arthurfp","download_url":"https://codeload.github.com/arthurfp/Go_Command_Pattern/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247957319,"owners_count":21024691,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-pattern","command","command-pattern","go","golang"],"created_at":"2024-12-22T15:15:12.152Z","updated_at":"2025-04-09T01:32:48.496Z","avatar_url":"https://github.com/arthurfp.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Command Pattern in Go\n\n## Overview\nThis repository demonstrates the application of the Command design pattern in Go. The project highlights how to encapsulate requests as objects, enabling parameterization, queuing, and undo functionality, showcasing flexibility and best practices in design patterns and unit testing.\n\n## Pattern Description\nThe Command pattern encapsulates a request as an object, thereby allowing you to parameterize clients with different requests, queue or log requests, and support undoable operations.\n\n### Key Components\n- **Command Interface**: Defines a method for executing a command.\n- **Concrete Commands**: Implement the Command interface and define bindings between a Receiver and an action.\n- **Receiver**: Knows how to perform the operations associated with a command.\n- **Invoker**: Stores commands and executes them in a structured manner.\n\n## Project Structure\n- **cmd/**: Contains the application entry point (`main.go`), demonstrating the creation and usage of commands.\n- **pkg/command/**: Houses the Command pattern implementation.\n    - **command.go**: Defines the `Command` interface.\n    - **receiver.go**: Implements the `Receiver`.\n    - **command_one.go**: Implements `CommandOne` to execute the first action.\n    - **command_two.go**: Implements `CommandTwo` to execute the second action.\n    - **invoker.go**: Implements the `Invoker` to manage and execute commands.\n    - **receiver_test.go**: Unit tests for the `Receiver`.\n    - **command_one_test.go**: Unit tests for `CommandOne`.\n    - **command_two_test.go**: Unit tests for `CommandTwo`.\n    - **invoker_test.go**: Unit tests for the `Invoker`.\n\n## Getting Started\n\n### Prerequisites\nEnsure you have Go installed on your system. You can download it from [Go's official site](https://golang.org/dl/).\n\n### Installation\nClone this repository to your local machine:\n```bash\ngit clone git@github.com:arthurfp/Go_Command_Pattern.git\ncd Go_Command_Pattern\n```\n\n### Running the Application\nTo run the application, execute:\n```bash\ngo run cmd/main.go\n```\n\n### Running the Tests\nTo execute the tests and verify the functionality:\n```bash\ngo test ./pkg/command\n```\n\n### Example Output\nWhen you run the application, you should see the following output:\n```yaml\nExecuting CommandOne:\nReceiver: Executing ActionOne\nExecuting CommandTwo:\nReceiver: Executing ActionTwo\nExecuting all commands via Invoker:\nReceiver: Executing ActionOne\nReceiver: Executing ActionTwo\n```\n\n### Contributing\nContributions are welcome! Please feel free to submit pull requests or open issues to discuss proposed changes or enhancements.\n\n### Author\nArthur Ferreira - github.com/arthurfp","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farthurfp%2Fgo_command_pattern","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farthurfp%2Fgo_command_pattern","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farthurfp%2Fgo_command_pattern/lists"}