How to print rune in golang?
April 07, 2022Hi Friends π,
Welcome To aGuideHub! β€οΈ
Today, we will learn to create and print rune
in golang, before going to the example we have to understand
What is a rune in goLang?
A rune is an int32 value, and therefore it is a Go type that is used for representing a Unicode code point. A Unicode code point or code position is a numerical value that is usually used for representing single Unicode characters;
For example, the rune literal βaβ is actually the number 97.
So letβs create a rune
variable and print it in golang console.
package main
import "fmt"
func main() {
r := []rune("abc");
fmt.Println(r)
}
In the above code, we are create rune variable with value of abc
and when print it so [97 98 99]
in unicode of there char.
All the best π