How to get length of a string in golang?
October 27, 2022Hi Friends 👋,
Welcome To aGuideHub! ❤️
To get length of a string, use len(str)
method it will count and return numbers of element of string.
In golang the len()
method used for counts element of string.
Let’s start
package main
import "fmt"
func main() {
str := "aGuideHub"
fmt.Println("Length of str", len(str))
}
In the above program, we are accessing length of string, let’s see the output.
Output:
Length of str 9
All the best 👍