My understanding was that a string had a pointer and a length, whereas a slice had a pointer and a length and a capacity.
https://golang.org/src/reflect/value.go?s=59515:59567#L1973 On Tuesday, 18 May 2021 at 20:32:39 UTC+1 Brian Candler wrote: > Assigning a string value to another variable doesn't double the memory > usage. > > A value of type string consists of a pointer, a length, and a capacity, > and only these are copied - so you get another copy of the pointer, > pointing to the same data buffer. > >> -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/951b1505-e6d7-42d0-b78e-cea207956281n%40googlegroups.com.