go

指针

Posted by 云起 on 2022-09-16
Estimated Reading Time 1 Minutes
Words 147 In Total
Viewed Times

指针

随写

  1. Go语言中的函数传参都是值拷贝

  2. 类型指针不能进行偏移和运算

  3. 当一个指针被定义后没有分配到任何变量时,它的值为 nil

  4. 引用类型的变量使用时不仅需要声明还需要分配内存空间

new与make

  1. 用于分配内存
  2. make只用于slice、map以及channel的初始化,返回的还是这三个引用类型本身
  3. new用于类型的内存分配,并且内存对应的值为类型零值,返回的是指向类型的指针

If you like this blog or find it useful for you, you are welcome to comment on it. You are also welcome to share this blog, so that more people can participate in it. If the images used in the blog infringe your copyright, please contact the author to delete them. Thank you !