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 👍

Premium Content

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

Books

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.

I'm working on some more Cheat Sheets book on Jquery, TypeScript, React js and for other languages. I will send it once it's completed.

Stay tuned working on React Js Cheat Sheets Book

Related Posts