Files
learngo/27-functional-programming/log-parser-exp/main.go
2019-08-06 03:32:44 +03:00

57 lines
988 B
Go

// For more tutorials: https://blog.learngoprogramming.com
//
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
package main
import (
"fmt"
"os"
)
func main() {
defer recoverErr()
_, err := newReport().
from(textReader(os.Stdin)).
to(textWriter(os.Stdout)).
// filterBy(orgDomainsFilter).
filterBy(notUsing(domainExtFilter("com", "io"))).
groupBy(domainGrouper).
start()
if err != nil {
fmt.Println("> Err:", err)
}
}
func recoverErr() {
val := recover()
if val == nil {
return
}
if err, ok := val.(string); ok {
fmt.Println("> Error occurred:", err)
}
}
/*
newReport -> report.New().
Result -> report.Line
notUsing = report.Not
_, err := report.New().
From(report.TextReader(os.Stdin)).
To(report.TextWriter(os.Stdout)).
// FilterBy(report.OrgDomainsFilter).
FilterBy(notUsing(report.DomainExtFilter("com", "io"))).
GroupBy(report.DomainGrouper).
Start()
*/