Go language program to find length of a string


Following program shows you how to find length of a string.
In this program we get string from user and prints the length using len()

package main

import "fmt"

func main() {

  var input string
  var lengthOfString int
  fmt.Println("Please enter the string:")
  fmt.Scanf("%s", &input)
  lengthOfString = len(input)
  fmt.Println("Length of the given string is: " , lengthOfString)
}

Output:

Please enter the string:
 hello
Length of the given string is:  5