Application
Create new folder named src. In src folder, create new file named main.go as below:
package main
import (
"fmt"
"strings"
)
func main() {
name1 := "mary"
name2 := "peter"
name3 := "anna"
name4 := "mary"
result1 := strings.Compare(name1, name2)
fmt.Println("result 1:", result1)
result2 := strings.Compare(name1, name3)
fmt.Println("result 2:", result2)
result3 := strings.Compare(name1, name4)
fmt.Println("result 3:", result3)
}
Output
Open Terminal windows in Visual Studio Code and run command line: go run main.go
result 1: -1
result 2: 1
result 3: 0