Does dereferencing a struct return a new copy of struct?

后端 未结 3 1730
-上瘾入骨i
-上瘾入骨i 2020-12-29 07:50

Why when we reference struct using (*structObj) does Go seem to return a new copy of structObj rather than return the same address of original

3条回答
  •  灰色年华
    2020-12-29 08:35

    tl;dr Dereferencing (using the * operator) in Go does not make a copy. It returns the value the pointer points to.

提交回复
热议问题