File tree 1 file changed +38
-0
lines changed
1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,45 @@ go get github.com/izniburak/pipeline-go
15
15
```
16
16
17
17
## Examples
18
+ ``` go
19
+ package main
18
20
21
+ import (
22
+ " fmt"
23
+ " strings"
24
+ " github.com/izniburak/pipeline-go"
25
+ )
26
+
27
+ type UpperCasePipe struct {}
28
+
29
+ func (u *UpperCasePipe ) Handle (value pipeline .PipeValue , next pipeline .PipeNext ) pipeline .PipeValue {
30
+ // get value
31
+ text := value.(string )
32
+ capitalized := strings.ToUpper (text)
33
+ return next (capitalized)
34
+ }
35
+
36
+ type TrimSpacePipe struct {}
37
+
38
+ func (t *TrimSpacePipe ) Handle (value pipeline .PipeValue , next pipeline .PipeNext ) pipeline .PipeValue {
39
+ // get value
40
+ text := value.(string )
41
+ trimmed := strings.Trim (text, " " )
42
+ return next (trimmed)
43
+ }
44
+
45
+ func main () {
46
+ text := " buki.dev "
47
+
48
+ pipes := []pipeline.PipeInterface {
49
+ new (UpperCasePipe),
50
+ new (TrimSpacePipe),
51
+ }
52
+ result := pipeline.Send (text).Through (pipes).ThenReturn ()
53
+
54
+ fmt.Println (result) // BUKI.DEV
55
+ }
56
+ ```
19
57
20
58
## Contributing
21
59
You can’t perform that action at this time.
0 commit comments