How to convert string to bytes in golang?

Member

nicola

by nicola , in category: Golang , 16 days ago

How to convert string to bytes in golang?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by craig , 16 days ago

@nicola Its's safe and easy to convert to use []byte in golang, some simple example:


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

import "fmt"

func main() {
   str := "computertips.info"

   // [99 111 109 112 117 116 101 114 116 105 112 115 46 105 110 102 111]
   fmt.Println([]byte(str))
}