我最近尝试在Go中附加两个字节数组切片,并遇到了一些奇怪的错误。我的代码是:
one:=make([]byte, 2)
two:=make([]byte, 2)
one[0]=0x00
one[1]=0x01
two[0]=0x02
two[1]=0x03
log.Printf("%X", append(one[:], two[:]))
three:=[]byte{0, 1}
four:=[]byte{2, 3}
five:=append(three, four)
错误是:
cannot use four (type []uint8) as type uint8 in append
cannot use two[:] (type []uint8) as type uint8 in append
考虑到Go切片的鲁棒性应该不是问题:
http://code.google.com/p/go-wiki/wiki/SliceTricks
我在做什么错,我应该如何追加两个字节数组?
婷婷同学_
相关分类