To check if two strings are equal ignoring case in Go, you can use the strings.EqualFold
function to perform a case-insensitive comparison.
In this example,
strings
package.str1
and str2
with different cases, such as "Hello"
and "hello"
.strings.EqualFold
function to compare the strings ignoring case.EqualFold
function returns true
if the strings are equal ignoring case, and false
otherwise.package main
import (
"fmt"
"strings"
)
func main() {
str1 := "Hello"
str2 := "hello"
result := strings.EqualFold(str1, str2)
fmt.Printf("Strings are equal ignoring case: %t", result)
}
Strings are equal ignoring case: true
In this tutorial, we learned How to check if Two Strings are Equal ignoring case in Go language with well detailed examples.