| 
									
										
										
										
											2019-08-06 01:34:36 +03:00
										 |  |  | // 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" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func main() { | 
					
						
							|  |  |  | 	defer recoverErr() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	_, err := newReport(). | 
					
						
							| 
									
										
										
										
											2019-08-07 13:24:15 +03:00
										 |  |  | 		// from(fastTextReader(os.Stdin)). | 
					
						
							| 
									
										
										
										
											2019-08-06 03:32:24 +03:00
										 |  |  | 		filterBy(notUsing(domainExtFilter("com", "io"))). | 
					
						
							| 
									
										
										
										
											2019-08-06 01:34:36 +03:00
										 |  |  | 		groupBy(domainGrouper). | 
					
						
							| 
									
										
										
										
											2019-08-06 03:32:24 +03:00
										 |  |  | 		start() | 
					
						
							| 
									
										
										
										
											2019-08-06 01:34:36 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	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) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* | 
					
						
							| 
									
										
										
										
											2019-08-06 01:49:48 +03:00
										 |  |  | newReport -> report.New(). | 
					
						
							|  |  |  | Result    -> report.Line | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | notUsing = report.Not | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-06 03:32:24 +03:00
										 |  |  | _, 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() | 
					
						
							| 
									
										
										
										
											2019-08-06 01:34:36 +03:00
										 |  |  | */ |