I am trying to search for or a particular words in the files in a directory and and convert each of its instance in all the file in Uppercase.
I want to keep track of the file where the word was found and how many time it appeared in those file.
So far I am able to read the content of the file.
How do send an argument then from the main function to search through the file and replace those instance into upper case?
This is what I have so far:
func visit(path string, fi os.FileInfo, err error) error {
if err!=nil{
return err
}
if !!fi.IsDir(){
return nil //
}
matched, err := filepath.Match("*.txt", fi.Name())
if err !=nil{
fmt.Println(err)
return err
}
if matched{
read,err:= ioutil.ReadFile(path)
fmt.Println(read)
check(err)
fmt.Println(path) }
return nil
}
func main() {
err := filepath.Walk(".", visit)
}