go string与[]byte相互转换

  • 代码如下:
/**
* @Author: wsp
* @Date: 9:42 2018/1/12
* @Description: io测试
 */
func IoTest1() {

    var param string = "hell world"

    // string to []byte
    b := []byte(param)
    fmt.Println(b)

    // []byte to string
    s := string(b)
    fmt.Println(s)
}