How to Convert Rune to String in Golang

To convert a rune to a string, you can use the “string()” function. In Go, a rune is an alias for the int32 type, representing a Unicode code point.


package main

import "fmt"

func main() {
  r := rune('K')

  // Convert rune to string
  s := string(r)
  fmt.Println("Rune as string:", s)


Rune as string: K

This code snippet demonstrates converting a rune (in this case, the letter ‘K’) to a string.

The string() function makes the conversion, and the result is printed to the console.

Leave a Comment