Searches for a partial or full match of a string If allowContains is true, the match can appear anywhere in the string. Otherwise it must start with the searchFor string
(searchFor string, searchIn string, allowContains bool)
| 355 | // If allowContains is true, the match can appear anywhere in the string. |
| 356 | // Otherwise it must start with the searchFor string |
| 357 | func stringMatch(searchFor string, searchIn string, allowContains bool) (partialMatch bool, fullMatch bool) { |
| 358 | |
| 359 | searchFor = strings.ToLower(searchFor) |
| 360 | searchIn = strings.ToLower(searchIn) |
| 361 | |
| 362 | if allowContains { |
| 363 | for _, word := range strings.Fields(searchIn) { |
| 364 | if strings.HasPrefix(word, searchFor) { |
| 365 | if searchIn == searchFor { |
| 366 | return true, true |
| 367 | } |
| 368 | return true, false |
| 369 | } |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | if strings.HasPrefix(searchIn, searchFor) { |
| 374 | if searchIn == searchFor { |
| 375 | return true, true |
| 376 | } |
| 377 | return true, false |
| 378 | } |
| 379 | |
| 380 | return false, false |
| 381 | } |
| 382 | |
| 383 | func Hash(input string) string { |
| 384 | return fmt.Sprintf("%x", sha256.Sum256([]byte(input))) |
no outgoing calls