FgrepStringInFile is a small hammer for looking for a literal string in a file. It should only be used against very modest sized files, as the entire file is read into a string.
(fullPath string, needle string)
| 223 | // It should only be used against very modest sized files, as the entire file is read |
| 224 | // into a string. |
| 225 | func FgrepStringInFile(fullPath string, needle string) (bool, error) { |
| 226 | fullFileBytes, err := os.ReadFile(fullPath) |
| 227 | if err != nil { |
| 228 | return false, err |
| 229 | } |
| 230 | fullFileString := string(fullFileBytes) |
| 231 | return strings.Contains(fullFileString, needle), nil |
| 232 | } |
| 233 | |
| 234 | // GrepStringInFile is a small hammer for looking for a regex in a file. |
| 235 | // It should only be used against very modest sized files, as the entire file is read |
no outgoing calls