How to convert byte array to string golang?

Member

craig

by craig , in category: Golang , 16 days ago

How to convert byte array to string golang?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by wiley , 16 days ago

@craig There is nothing difficult to convert array of bytes to string back, take a look my example below(you can use method string() in golang and pass your []byte):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
package main

import "fmt"

func main() {
   bytes := []byte("custom text")

   // custom text
   fmt.Println(string(bytes))
}