https://github.com/cekrem/go-transform
https://github.com/cekrem/go-transform
dependency-inversion-principle go golang plugins
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/cekrem/go-transform
- Owner: cekrem
- Created: 2025-01-07T11:14:48.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-02-13T11:35:34.000Z (over 1 year ago)
- Last Synced: 2025-02-13T12:32:17.808Z (over 1 year ago)
- Topics: dependency-inversion-principle, go, golang, plugins
- Language: Go
- Homepage: https://cekrem.github.io/posts/clean-architecture-and-plugins-in-go/
- Size: 11.7 KB
- Stars: 18
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-transform
A flexible Go-based text transformation tool that uses a plugin architecture to process input streams. This project demonstrates the Dependency Inversion Principle with three distinct layers, emphasizing modularity through its plugin system.
I wrote about an earlier version of this project [on my blog](https://cekrem.github.io/posts/clean-architecture-and-plugins-in-go/), check it out for more context.
## Features
- Plugin-based architecture for extensible text transformations
- Clean separation of concerns following Clean Architecture principles
- Simple CLI interface
## Prerequisites
- Go 1.23 or later
- Make
## Installation
```bash
# Clone the repository
git clone https://github.com/cekrem/go-transform.git
cd go-transform
# Build the main application and plugins
make
```
## Usage
The tool reads from standard input and writes to standard output:
```bash
# Using the default passthrough transformer
echo "Hello, World!" | ./build/transform
# Using a specific transformer
echo "Hello, World!" | ./build/transform -transformer=passthrough
```
## Project Structure
```
.
├── cmd/ # Application entrypoint
├── pkg/
│ └── domain/ # Core business rules and interfaces
├── internal/
│ └── app/ # Application logic
│ └── processor/ # Transformation orchestration
└── plugins/ # Infrastructure implementations (plugins)
```
## Architecture
This project demonstrates Clean Architecture principles with three layers:
### Domain Layer (`pkg/domain`)
- Contains core business rules and interfaces
- Has no external dependencies
- Defines what transformers should do
- `Transformer` and `Plugin` interfaces
### Application Layer (`internal/app`)
- Contains core application logic
- Depends only on domain interfaces
- Coordinates the transformation process
- `Processor` that manages plugins and executes transformations
### Infrastructure Layer (`plugins`)
- Contains concrete implementations
- Depends on domain interfaces
- Implements specific transformation strategies
- `passthrough` plugin
The project follows the Dependency Inversion Principle by:
1. Defining abstractions in the domain layer
2. Having both application and infrastructure layers depend on domain interfaces
3. Ensuring all dependencies point toward the domain layer
## Development
### Creating New Plugins
Plugins should be created in the `plugins` directory and implement the transformer interface from the domain layer. See the `passthrough` plugin for an example implementation.
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.