package main
import (
"fmt"
"strings"
)
func main() {
// Define the string we want to search in
s := "golang"
// Check for a rune using ContainsRune
posG := strings.ContainsRune(s, 'g') // true
posZ := strings.ContainsRune(s, 'z') // false
// Print the raw boolean results
fmt.Println(posG)
fmt.Println(posZ)
// Conditional check
if strings.ContainsRune(s, 'g') {
fmt.Println("exists")
} else {
fmt.Println("not exists")
}
}
/*
run:
true
false
exists
*/