The Go Programming Language
› http://golang.org/
› Go Playground
Go Projects
› Revel Web Framework
justonelastdance

go 能不用指针就尽量不用指针

  •  
  •   justonelastdance · Aug 22, 2023 · 2055 views
    This topic created in 1195 days ago, the information mentioned may be changed or developed.
    指针是分配在堆上的,会造成内存逃逸。
    在用结构体的时候,尽量不要用指针,更不要在函数里返回指针。
    k9982874
    k9982874
    Aug 22, 2023❤️3
    1
    ???????????
    Cola98
    Cola98
    Aug 22, 2023
    2
    但是使用指针可以减少内存占用率吧?而且指针一部分是放在栈上的,指向堆上内存。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4784 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 03:31 · PVG 11:31 · LAX 19:31 · JFK 22:31
    ♥ Do have faith in what you're doing.