ring.Link() Function in Golang With Examples Last Updated : 17 May, 2020 Comments Improve Suggest changes Like Article Like Report ring.Link() function in Golang is used to connect two ring r and ring s ring.next() function connect last node of ring r to first node of ring s .so that for r.next() must not be empty. Otherwise, it will throw an error. It works like a circular linked list. Syntax: func (r *Ring) Link(s *Ring) *Ring It does not return anything. Example 1: C // Golang program to illustrate // the ring.Link() function package main import ( "container/ring" "fmt" ) // Main function func main() { // Create two rings, a and b, of size 2 a := ring.New(4) b := ring.New(4) // Get the length of the ring m := a.Len() n := b.Len() // Initialize a with 0s for j := 0; j < m; j++ { a.Value = 0 a = a.Next() } // Initialize b with 1s for i := 0; i < n; i++ { b.Value = 1 b = b.Next() } // Link ring a and ring b ab := a.Link(b) ab.Do(func(p interface{}) { fmt.Println(p.(int)) }) } Output: 0 0 0 0 1 1 1 1 Example 2: C // Golang program to illustrate // the ring.Link() function package main import ( "container/ring" "fmt" ) // Main function func main() { // Create two rings, r and s, of size 2 r := ring.New(2) s := ring.New(2) // Get the length of the ring lr := r.Len() ls := s.Len() // Initialize r with "GFG" for i := 0; i < lr; i++ { r.Value = "GFG" r = r.Next() } // Initialize s with "COURSE" for j := 0; j < ls; j++ { s.Value = "COURSE" s = s.Next() } // Link ring r and ring s rs := r.Link(s) // Iterate through the combined // ring and print its contents rs.Do(func(p interface{}) { fmt.Println(p.(string)) }) } Output: GFG GFG COURSE COURSE Comment More infoAdvertise with us Next Article ring.Link() Function in Golang With Examples vipinyadav15799 Follow Improve Article Tags : Go Language Similar Reads ring.Len() Function in Golang With Examples ring.Len() function in Golang computes the number of components(elements) in ring(a circular list) r. It executes in time corresponding to the number of components(elements). Syntax: func (r *Ring) Len() int It returns Integer. Example 1: C // Golang program to illustrate // the ring.Len() function 1 min read strings.Join() Function in Golang With Examples strings.Join() Function in Golang concatenates all the elements present in the slice of string into a single string. This function is available in the string package. Syntax: func Join(s []string, sep string) string Here, s is the string from which we can concatenate elements and sep is the separato 1 min read strings.Index() Function in Golang With Examples strings.Index() Function in Golang is used to get the first instance of a specified substring. If the substring is not found, then this method will return -1. Syntax: func Index(str, sbstr string) int Here, str is the original string and sbstr is a string whose we want to find index value. Example 1 2 min read reflect.String() Function in Golang with Examples Go language provides inbuilt support implementation of run-time reflection and allowing a program to manipulate objects with arbitrary types with the help of reflect package. The reflect.String() Function in Golang is used to get the string v's underlying value, as a string. To access this function, 2 min read strings.Map() Function in Golang With Examples strings.Map() Function in Golang is used to return a copy of the string given string with all its characters modified according to the mapping function. If mapping returns a negative value, the character is dropped from the string with no replacement. So whenever the user wants to make changes in a 2 min read strings.IndexByte() Function in Golang With Examples strings.IndexByte() Function in Golang returns the index of the first instance of the given byte in the original string. If the given byte is not available in the original string, then this method will return -1. Syntax: func IndexByte(str string, b byte) int Here, str is the original string and b i 1 min read strings.IndexFunc() Function in Golang With Examples strings.IndexFunc() Function in Golang is used to returns the index into s of the first Unicode code point satisfying f(c), or -1 if none do. Syntax: func IndexFunc(str string, f func(rune) bool) int Here, str is string which may contain Unicode code point and f is func which validates the Unicode p 1 min read strings.IndexRune() Function in Golang With Examples strings.IndexRune() Function in Golang is used to find the first index of the specified rune in the given string. It is defined under the string package so, you have to import string package in your program for accessing IndexRune function Syntax: func IndexRune(str string, r rune) int This function 2 min read reflect.Int() Function in Golang with Examples Go language provides inbuilt support implementation of run-time reflection and allowing a program to manipulate objects with arbitrary types with the help of reflect package. The reflect.Int() Function in Golang is used to get the v's underlying value, as an int64. To access this function, one needs 1 min read fmt.print() Function in Golang With Examples In Go language, fmt package implements formatted I/O with functions analogous to C's printf() and scanf() function. The fmt.print() function in Go language formats using the default formats for its operands and writes to standard output. Here Spaces are added between operands when any string is not 2 min read Like