1
0
mirror of https://github.com/golang/go synced 2024-11-24 19:20:03 -07:00

make string take []byte only, so have to use *[10]byte to convert

R=r
DELTA=4  (0 added, 0 deleted, 4 changed)
OCL=27578
CL=27584
This commit is contained in:
Russ Cox 2009-04-16 23:07:15 -07:00
parent ea12ed4fdd
commit e2bf22715d
2 changed files with 4 additions and 4 deletions

View File

@ -8,12 +8,12 @@ package main
func main() { func main() {
var b [0]byte; var b [0]byte;
s := string(b); // out of bounds trap s := string(&b); // out of bounds trap
if s != "" { if s != "" {
panic("bad convert") panic("bad convert")
} }
var b1 = [5]byte{'h', 'e', 'l', 'l', 'o'}; var b1 = [5]byte{'h', 'e', 'l', 'l', 'o'};
if string(b1) != "hello" { if string(&b1) != "hello" {
panic("bad convert 1") panic("bad convert 1")
} }
var b2 = make([]byte, 5); var b2 = make([]byte, 5);

View File

@ -86,7 +86,7 @@ main()
z1[0] = 'a'; z1[0] = 'a';
z1[1] = 'b'; z1[1] = 'b';
z1[2] = 'c'; z1[2] = 'c';
c = string(z1); c = string(&z1);
if c != "abc" { if c != "abc" {
panic("create array ", c); panic("create array ", c);
} }
@ -96,7 +96,7 @@ main()
z2[0] = 'a'; z2[0] = 'a';
z2[1] = 'b'; z2[1] = 'b';
z2[2] = 'c'; z2[2] = 'c';
c = string(*z2); c = string(z2);
if c != "abc" { if c != "abc" {
panic("create array pointer ", c); panic("create array pointer ", c);
} }