I'd like to be able to determine whether stringB is a case-insensitive substring of stringA. Looking through Go's strings
pkg, the closest I can get is strings.Contains(strings.ToLower(stringA), strings.ToLower(stringB)
. Is there a less wordy alternative that I'm not seeing?
If it's just the wordiness that you dislike, then how about making your code formatting cleaner, e.g.:
strings.Contains(
strings.ToLower(stringA),
strings.ToLower(stringB),
)
Or hiding it in a function in your own utils
(or whatever) package:
package utils
import "strings"
func ContainsI(a string, b string){
return strings.Contains(
strings.ToLower(a),
strings.ToLower(b),
)
}