[go-nuts] Re: Confused about heap usage for empty slices

2022-09-07 Thread 'Keith Randall' via golang-nuts
(Actually, that address is an address on the stack, but that's only because the backing store for emptySlice does not escape. It should also take ~no space.) On Wednesday, September 7, 2022 at 4:53:12 PM UTC-7 Keith Randall wrote: > That address is not in the heap. It is the address of a specia

[go-nuts] Re: Confused about heap usage for empty slices

2022-09-07 Thread 'Keith Randall' via golang-nuts
That address is not in the heap. It is the address of a special word in the runtime, called runtime.zerobase, which is explicitly for this purpose. It is a place to point things that need to be non-nil but have no size. On Wednesday, September 7, 2022 at 12:01:28 PM UTC-7 me...@pobox.com wrote:

[go-nuts] Confused about heap usage for empty slices

2022-09-07 Thread mathew murphy
Running this: emptyslice := []string{} sh := (*reflect.SliceHeader)(unsafe.Pointer(&emptyslice)) fmt.Printf("empty slice cap = %d\n", sh.Cap) fmt.Printf("empty slice len = %d\n", sh.Len) fmt.Printf("empty slice uintptr = %v\n", sh.Data) Output: empty slice cap = 0 empty slice len = 0 emp

Re: [go-nuts] Assigning struct values

2022-09-07 Thread burak serdar
On Wed, Sep 7, 2022 at 12:28 PM Mustafa Durukan wrote: > > > *fakeObject := tt.Object.(TypeOfStruct)object := Object.(TypeOfStruct)* If you can include the definitions of tt, explain what you want to do, and what you mean by "didn't work", someone may be able to answer this question. Without t

[go-nuts] Assigning struct values

2022-09-07 Thread Mustafa Durukan
*fakeObject := tt.Object.(TypeOfStruct)object := Object.(TypeOfStruct)fakeObject.Field = object.FieldfakeObject.Field2 = object.Field2* I have case like that. I want to assign sme object values to tt.Object but when i try to assign it assings to fakeObject i mean copy of tt.Object so I cant