This section will illustrate how to add support for regular expressions in finalFind.go: the name of the last version of the tool will be regExpFind.go. The new flag will be called -re and it will require a string value: anything that matches this string value will be included in the output unless it is excluded by another command-line option. Additionally, due to the flexibility that flags offer, we do not need to delete any of the previous options in order to add another one!
Once again, the diff(1) command will tell us the code differences between regExpFind.go and finalFind.go:
$ diff regExpFind.go finalFind.go 8d7 < "regexp" 36,44d34 < func regularExpression(path, regExp string) bool { < if regExp == "" { < return true < } < r, _ := regexp.Compile(regExp) < matched := r.MatchString...