Example:
type MyString string
var s = "very long string"
var ms = MyString(s)
var s2 = string(s)
Are ms
or s2
a full copy of s
(as it would be done with []byte(s)
)? Or they are just a string struct copies (which keeps the real value in a pointer)?
What if we are passing this to a function? E.g.:
func foo(s MyString){
...
}
foo(ms(s)) // do we copy s here?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…