Go 문자열을 바이트 슬라이스로 변환

1 개요[ | ]

Go 문자열을 바이트 배열로 변환
Go 문자열을 바이트 슬라이스로 변환
  • 문자열 변수를 []byte()로 감싸면 된다.
package main

import "fmt"

func main() {
    var str string = "hello"
    var byts []byte = []byte(str)
    fmt.Printf("%#v", byts) // []byte{0x68, 0x65, 0x6c, 0x6c, 0x6f}
}

2 같이 보기[ | ]

3 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}