Jay, A Go string is represented by a struct.
type stringStruct struct { str unsafe.Pointer len int } Assigning a new value to a string variable is a struct assignment that does not immediately destroy the underlying value of the original string. Peter On Tuesday, August 28, 2018 at 10:55:27 AM UTC-4, Jay Sharma wrote: > > Hi All, > > I went through documentation and many post. Every where it is specified > *strings > are immutable*. > > I have some string : > > x := "teststring" > > > I want to *wipe out/overwrite* the content of this string x from > disk/memory. > > As per me the simplest way to do this: > > x = "" > > > or If I want to overwrite it with some new content, I can do this: [*Here > length of new string is equal to length of old string*] > > x = "new1string" > > > As I am overwriting the content with new content, Is it *inplace > replacement* [same memory is being updated] or a new copy will be created > with new content and old content will be there in the memory ? > > > -- 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. For more options, visit https://groups.google.com/d/optout.