In this tutorial we are going to see how can we convert rune type to int in golang.
rune to int conversion
var ch rune = '#'
var intValue int = int( ch)
complete Golang program for rune to int conversion
package main
import "fmt"
func main() {
var ch rune = '#'
var intValue int = int(ch)
fmt.Println(intValue)
fmt.Println(ch) // here we will also get int value of rune type
}
Note – If we directly print a rune without using format specifier then we will get an integer value as output because the rune is the alias of the int32 type.
you can also check this video – ‘working with rune in Golang’
1 thought on “Golang rune to int”