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

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

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