To repeat a String a few number of times, Go provides us with a Function called 'Repeat()' that repeats a string a few number of times.
Let us see the below example.
package main import "fmt" import "strings" func main() { x := "Hello" y := strings.Repeat(x,3) fmt.Println(y) }
So, if you see the output. The statement,
Repeats the String 'Hello' three times.
Now, to use the Repeat() Function, you need to import 'strings'.
As the Function Repeat() is defined in 'strings'.
Then you use 'strings' to invoke the Repeat() Function, passing the actual string to be repeated (i.e. 'x := "Hello"') and number of times the string has to be repeated(i.e. '3').