package main
import (
"fmt"
"strings"
)
// Case-insensitive check without a loop
func charExistsIgnoreCase(s string, target byte) bool {
// Convert both to lowercase and use Contains()
return strings.Contains(strings.ToLower(s), strings.ToLower(string(target)))
}
func main() {
// Define the string we want to search in
s := "GoLanguage"
// Perform the case-insensitive check
exists := charExistsIgnoreCase(s, 'g')
// Print the raw boolean result
fmt.Println(exists)
// Conditional check
if exists {
fmt.Println("exists")
} else {
fmt.Println("not exists")
}
}
/*
run:
true
exists
*/