[Go] Convert a byte slice to a string

Created on November 30, 2026

Use a type conversion such as string(bytes) to convert []byte to string. This example converts the bytes for hello and prints the resulting type.

package main

import (
    "fmt"
    "reflect"
)

func main() {
    bytes := []byte("hello")
    str := string(bytes)
    fmt.Println(reflect.TypeOf(str))
}

Output

string
Go