How to print byte array in golang?

Hi Friends 👋,

Welcome To aGuideHub! ❤️

Today, we will learn to print byte array in golang, here we will use the fmt.print() method to show byte array in output.

Let’s create some byte array type variable.

package main
import "fmt"

func main() {
  b := []byte("ABC€")
  s := []byte{65, 66, 67, 226, 130, 172}
  fmt.Print(b);
  fmt.Print("\n");
  fmt.Print(s);
}

In the above code, we have created two variables and print one after one for the output following the below image.

print, byte array, golang

Try it yourself

All the best 👍

Follow me on Twitter