August 2019
Beginner to intermediate
798 pages
17h 2m
English
This section will illustrate the use of the container/ring package using the Go code of conRing.go, which will be presented in four parts. Note that the container/ring package is much simpler than both container/list and container/heap, which means that it contains fewer functions than the other two packages.
The first code segment of conRing.go follows:
package main
import (
"container/ring"
"fmt"
)
var size int = 10
The size variable holds the size of the ring that is going to be created.
The second part of conRing.go contains the following Go code:
func main() { myRing := ring.New(size + 1) fmt.Println("Empty ring:", *myRing) for i := 0; i < myRing.Len()-1; i++ { myRing.Value = i myRing = myRing.Next() } myRing.Value ...Read now
Unlock full access