Automatically Converts char type to integer type


(Mangal Arora) #1

var s = ‘a’
fmt.Printf("%T is type of s\n",s)
fmt.Println(s)

Output:
int32 type of s
97


(Norbert Melzer) #2

This is as documented in the specs:

https://golang.org/ref/spec#Numeric_types

rune        alias for int32

(Mangal Arora) #3

Thank You Sir For letting me know.