Answers for "golang string to byte []"

Go
4

golang string to bytes

hello := []byte("hello-world")
Posted by: Guest on February-10-2021
0

golang convert string to bytes and convert bytes to string

package main
 
import (
    "fmt"
)
 
func main() {
    var s string = "Hello World"
    sb := []byte(s)
     
    fmt.Println(sb)  // [72 101 108 108 111 32 87 111 114 108 100]
     
    fmt.Println(string(sb)) // Hello World
}
Posted by: Guest on December-29-2021

Browse Popular Code Answers by Language