Len() function of ring package is used to get the length of circular linked list or ring in go. This function is a part of ring package.
Len() function prototype of ring package:
func (r *Ring) Len() int
Return value of Len() function of ring package::
Len() returns number of elements in circular linked list aka ring. It also executes in time proportional to the number of elements.
Example of Len() function in ring package:
package main import ( "container/ring" "fmt" ) func main() { // Create a new ring of size 10 ri := ring.New(10) // Get the length of the ring n := ri.Len() fmt.Println("Length: ", n) }
Output:
Length: 10
To learn more about golang, Please refer given below link:
References: