Posts

Showing posts from March 1, 2019

Go grep command clone

Image
3 I am trying to make a simple clone of the command line utility grep . I'm working on it just for fun and to practice Go. The thing is, I am trying to make it in a way that if several files are given at the command line, a different goroutine is generated to speed up the process. Even so, standard grep still gets results faster by an amount of around 60% less processing time. Here it is the code for it. Can you please provide some opinions about it? package main import ( "bufio" "flag" "fmt" "io" "os" "path/filepath" "regexp" "sync" ) type result struct { Filename string Line string LineNumber int Error error } var strRex string var filenames strin