how to convert rune to string in golang?
September 13, 2022Hi Friends 👋,
Welcome To aGuideHub! ❤️
To convert rune to string in golang, just use string()
method it will convert rune to string. Only you have to pass rune in the string()
.
Follow the below tutorial if you are struggling with installing GO in windows.
https://aguidehub.com/blog/how-to-install-golang-in-windows/
Today, I will show you how do I convert rune to string in golang, as above mentioned I’m going to use string()
way.
Let’s start our Golang convert rune to string example
main.go
package main
import "fmt"
func main() {
// convert rune to string
r := rune('a')
fmt.Println(string(r))
// convert array of rune to string
ar := []rune("abc")
fmt.Println(string(ar))
}
In the above example, we have converted rune and array of rune to string and printed in golang console. let’s check the output.
Output
a
abc
I hope it helps you, All the best 👍.