Can Golang multiply strings like Python can? -
python can multiply strings so: python 3.4.3 (default, mar 26 2015, 22:03:40) [gcc 4.9.2] on linux type "help", "copyright", "credits" or "license" more information. >>> x = 'my new text long' >>> y = '#' * len(x) >>> y '########################' >>> can golang equivalent somehow? it has function instead of operator, strings.repeat . here's port of python example: package main import ( "fmt" "strings" "unicode/utf8" ) func main() { x := "my new text long" y := strings.repeat("#", utf8.runecountinstring(x)) fmt.println(y) } note i've used utf8.runecountinstring(x) instead of len(x) ; former counts "runes" (unicode code points), while latter counts bytes. in case of "my new text long" , difference doesn't matter since characters 1 byte, it's habit of specif...