Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/niedbalski/filterchain
A simple Golang filter chain pattern implementation
https://github.com/niedbalski/filterchain
Last synced: about 1 month ago
JSON representation
A simple Golang filter chain pattern implementation
- Host: GitHub
- URL: https://github.com/niedbalski/filterchain
- Owner: niedbalski
- License: mit
- Created: 2018-07-11T17:41:03.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-11T18:30:53.000Z (over 6 years ago)
- Last Synced: 2024-10-15T08:32:40.211Z (3 months ago)
- Language: Go
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go-filterchain
[![GoDoc](https://godoc.org/github.com/golang/gddo?status.svg)](http://godoc.org/github.com/niedbalski/filterchain)
[![Build Status](https://travis-ci.org/niedbalski/filterchain.svg?branch=master)](https://travis-ci.org/niedbalski/filterchain)very simple implementation of a filter chain pattern written in Golang.
### Usage
```go
package mainimport (
"github.com/niedbalski/filterchain"
"strings"
"fmt"
)type TestToLowerFilter struct {}
type TestRepeatFilter struct {}func (filter TestToLowerFilter) Apply(t interface{}) (interface{}) {
return strings.ToLower(t.(string))
}func (filter TestRepeatFilter) Apply(t interface{}) (interface{}) {
return strings.Repeat(t.(string), 3)
}func main() {
fmt.Println(filterchain.New(TestToLowerFilter{}, TestRepeatFilter{}).Apply("TEST"))
}```
String will be produced as:```shell
testtestest
```