GO language program with example of String Compare function
String Compare function in Go language returns integer value -1, 0 or 1 after comparing two strings lexicographically. The result will be 0 if S1==S2, -1 if S1 < S2, and +1 if S1 > S2.
Example
// GO language program using String Compare function
package main
import (
"fmt"
"strings"
)
func main() {
fmt.Println(strings.Compare("India", "Indiana"))
fmt.Println(strings.Compare("Indiana", "India"))
fmt.Println(strings.Compare("India", "India"))
}
Output
-1
1
0
Most Helpful This Week
GO Program to Find the Largest Number Among Three Numbers
GO supports the standard arithmetic operators: (Addition, Subtraction, Multiplication, Division,Remainder)
GO Program to Check Whether a Number is Even or Odd
Program in Go language to print Floyd's Triangle
GO language program with example of Sort Functions for integer, strings and float64 data type
Program in Go language to Calculate Average Using Arrays