How to reverse a string in Go: reverse character order
Hi everyone! I just started learning Go and came across a seemingly simple task — reversing a string. In Python, I would write `'hello'[::-1]` and get `'olleh'`. In Go, I tried to do it like this:
```go
package main
import "fmt"
func reverse(s string) string {
var result string
for i := len(s) - 1; i >= 0; i-- {
result += string(s[i])
}
return result
}
func main() {
fmt.Println(reverse("hello")) // Outputs: olleh
}
```
With an ASCII string like "hello" this works. But when I tried to reverse the Russian word "привет" or a string with emoji, for example "👋Привет", I got complete gibberish. For "привет" it outputs something like "тверип" — it looks similar, but not quite right, and for emoji it outputs garbage.
I understand that pro