Golang container/ring.Ring.Do() function example
package container/ring
Do calls function f (1st parameter) on each element of the ring, in forward order. The behavior of Do is undefined if f changes *r. (see http://golang.org/pkg/container/ring/#Ring.Do)
Golang container/ring.Ring.Do() function usage example
package main
import (
"container/ring"
"fmt"
)
func main() {
r := ring.New(10)
i := 0
f := func(v interface{}) {
v = i
i++
fmt.Printf("%d\n", v)
}
r.Do(f)
}
Output :
0
1
2
3
4
5
6
7
8
9
Reference :
Advertisement
Something interesting
Tutorials
+16k Golang : Read large file with bufio.Scanner cause token too long error
+6.7k Golang : Derive cryptographic key from passwords with Argon2
+8.6k Golang : Another camera capture GUI application with GTK and OpenCV
+27.5k Golang : Convert integer to binary, octal, hexadecimal and back to integer
+16.9k Golang : How to generate QR codes?
+22k Fix "Failed to start php5-fpm.service: Unit php5-fpm.service is masked."
+12.1k Golang : Pagination with go-paginator configuration example
+10.5k Golang : Create matrix with Gonum Matrix package example
+8.9k Golang : Gaussian blur on image and camera video feed examples
+7.4k Golang : Scanf function weird error in Windows
+12.1k Golang : convert(cast) string to integer value
+14.5k Golang : Overwrite previous output with count down timer