how to convert byte array to string in golang?

Hi Friends 👋,

Welcome To aGuideHub! ❤️

To convert byte array to string in golang, use the string() method it will convert your array to string and return the converted string.

Follow the below tutorial if you are struggling with installing GO in windows.

Today, I will show you how do i convert byte array to string in golang, as above mentioned I’m going to use the string() method.

To use the string() method, we have to pass the byte array as a parameter then the string method will convert and return the byte array as a string.

Let’s start our Golang convert byte array to string example


package main

import (

func main() {
    byteArray := []byte{'a', 'G', 'u', 'i', 'd', 'e', 'H', 'u', 'b'}
    str1 := string(byteArray[:])
    fmt.Println("String =", str1)



String = aGuideHub
Program exited.

Try it Yourself

I hope it helps you, All the best 👍.

Premium Content

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


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