2014-12-04 49 views
1

確實從string轉換爲[]byte分配新內存?另外,是否從[]byte轉換爲string分配新的內存?有關從Golang []字節和字符串轉換的技術

s := "a very long string" 
b := []byte(s) // does this doubled the memory requirement? 

b := []byte{1,2,3,4,5, ...very long bytes..} 
s := string(b) // does this doubled the memory requirement? 

回答