https://github.com/parinpan/pipe
Pipe is a clone of Clojure's Threading Macros concept.
https://github.com/parinpan/pipe
clojure go-library golang macros syntactic-sugar
Last synced: 4 months ago
JSON representation
Pipe is a clone of Clojure's Threading Macros concept.
- Host: GitHub
- URL: https://github.com/parinpan/pipe
- Owner: parinpan
- License: apache-2.0
- Created: 2021-02-12T12:06:16.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-02-23T02:40:19.000Z (over 4 years ago)
- Last Synced: 2024-06-20T14:20:38.048Z (12 months ago)
- Topics: clojure, go-library, golang, macros, syntactic-sugar
- Language: Go
- Homepage:
- Size: 19.5 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
Pipe is a clone of Clojure's Threading Macros concept. It offers simplicity to construct a series of function executions in a syntactic sugar way.
## Installation
```
go get -u github.com/parinpan/pipe
```## Usage
See the full example here: https://github.com/parinpan/pipe/blob/master/example/pipe_implementation.go
```golang
result := pipe.Do(
pipe.Apply(funcA),
pipe.Apply(funcB),
pipe.Apply(funcC),
pipe.Apply(funcD),
)fmt.Printf("%+v\n", result)
// more advanced usage
result := pipe.Do(
pipe.Apply(getRestaurants),
pipe.Apply(getFoodsWithFilter, 10, pipe.Pass(), 5),
pipe.Apply(getFoodPrices),
pipe.Apply(getFoodTotalPriceText, pipe.Pass(func(prices []int) int {
var totalPrice = 0for _, price := range prices {
totalPrice += price
}return totalPrice
})))fmt.Printf("%+v\n", result)
```