how to convert rune to string in golang?

Hi 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 👍.

Try it Yourself

Premium Content

You can get all the below premium content directly in your mail when you subscribe us

Books

Interview Questions

Soon You will get CSS, JavaScript, React Js, and TypeScript So Subscribe to it.

Portfolio Template

View | Get Source Code

Cheat Sheets

Cheat Sheets Books are basically Important useful notes which we use in our day-to-day life.

Related Posts