strings.EqualFold() Function in Golang With Examples

strings.EqualFold() Function in Golang reports whether s and t, interpreted as UTF-8 strings, are equal under Unicode case-folding, which is a more general form of case-insensitivity.

Syntax:

func EqualFold(s1, s2 string) bool

Here, s1 and s2 are string.

Return Value: It returns the boolean value.

Example 1:



filter_none

edit
close

play_arrow

link
brightness_4
code

// Golang program to illustrate the
// strings.EqualFold() Function
package main
  
// importing fmt and strings
import (
    "fmt"
    "strings"
)
  
// calling main method
func main() {
    // case insensitive comparing and returns true.
    fmt.Println(strings.EqualFold("Geeks", "Geeks"))
  
    // case insensitive comparing and returns true.
    fmt.Println(strings.EqualFold("computerscience", "computerscience"))
}

chevron_right


Output:

true
true

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Golang program to illustrate the
// strings.EqualFold() Function
package main
  
// importing fmt and strings
import (
    "fmt"
    "strings"
)
  
// calling main method
func main() {
  
    // case insensitive comparing and returns true.
    fmt.Println(strings.EqualFold("Geeks", "geeks"))
  
    // case insensitive comparing and returns true.
    fmt.Println(strings.EqualFold("COMPUTERSCIENCE", "computerscience"))
}

chevron_right


Output:

true



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.