In Go programming language, you can compare two strings for equality using the ==
operator. Here's an example:
package main
import "fmt"
func main() {
str1 := "Hello"
str2 := "Hello"
if str1 == str2 {
fmt.Println("Strings are equal")
} else {
fmt.Println("Strings are not equal")
}
}
In this example, the ==
operator is used to compare str1
and str2
for equality. If the two strings are equal, "Strings are equal" will be printed; otherwise, "Strings are not equal" will be printed.