How to iterate over string characters in Go
To iterate over the characters in a string, a for..range
loop may be utilised.
This outputs the Unicode code point for each character in the string:
If you need to access the characters represented by the Unicode code point, you
can use the %c
fmt verb with fmt.Printf
or fmt.Sprintf
:
Thanks for reading, and happy coding!