测试例子
package main import (
"fmt"
) func main() {
str2 := "hello" data2 := []byte(str2)
fmt.Println(data2) str2 = string(data2[:])
fmt.Println(str2)
}
测试结果:
[root@localhost ]# go run d.go
[ ]
hello
测试例子
package main import (
"fmt"
) func main() {
str2 := "hello" data2 := []byte(str2)
fmt.Println(data2) str2 = string(data2[:])
fmt.Println(str2)
}
测试结果:
[root@localhost ]# go run d.go
[ ]
hello