A simple, efficient tool to search for specific text occurrences within files in a directory. This tool can be used both as a Go package.
- Traverse directories and search for text in files.
- Count occurrences of the specified text in all files.
- Exclude file extensions
- Simple, lightweight, and easy to integrate.
To use this tool in your Go project, install it via:
go get github.com/3cognito/gofind
Import the package into your project:
import "github.com/3cognito/gofind"
Use the tool in your Go code to search for text:
package main
import (
"fmt"
"log"
"github.com/3cognito/gofind"
)
func main() {
count := gofind.CountOccurrences("example.txt", "search_term", ".gitignore,.git")
fmt.Printf("Occurrences found: %d
", count)
}
This will output the total occurrences of search_term
across all files in the specified directory except those with the extensions .gitignore
and .git
.
Contributions are welcome! Feel free to open issues or submit pull requests.
This project is licensed under the MIT License.