How to Convert Rune to Int in Golang

To convert a rune to an int in Go, you can use the “int()” function.

package main

import "fmt"

func main() {
  r := 'B'

  intValue := int(r)

  fmt.Println("Rune as int:", intValue)


Rune as int: 66

In this code example, a rune “r” represents the Unicode code point for the letter “B”.

You can see that we used the “int(r)” function to perform the type conversion, and the result is printed to the console.