• Go 中没有引用传递

    先说清楚,在 go 中没有引用变量,所以更不存在什么引用传值了。 ## 什么是引用变量 在类 C++ 语言中,你可以声明一个别名,给一个变量安上一个其他名字,我们把这称为引用变量。 ```c #include <stdio.h> int main() { int a = 10; int &b = a; int &c = b; printf("%p %p %p\n", &a, &b, &c); // 0x7ffe114f0b14 0x7ffe114f0...

  • 重新学习 slice By Dave Cheney

    ## 数组 Arrays 每次讨论到 Go 的切片问题,都会从这个变量是不是切片开始,换句话说,就是 Go 的序列类型,在 Go 中,数组有两种关联属性。 1. 数组拥有固定的大小;`[5]int` 即表明是一个有 5 个 `int` 的数组,又与 `[3]int` 相区分开。 2. 他们是值类型。思考下面这个例子。 ```go package main import "fmt" func main() { var a [5]int b := a b[2] ...

  • 120
    Go: Goroutine 的堆栈大小是如何演进的

    ![](https://raw.githubusercontent.com/studygolang/gctt-images/master/how-goroutine-stack-size-evolve/cover.png) > Illustration created for “A Journey With Go”, made from the original Go Gopher, created by Renee French. *本文基于 Go 1.12* Go 提供了一...

  • 120
    Go 中的循环是如何转为汇编的?

    ![Illustration created for “A Journey With Go”, made from the original Go Gopher, created by Renee French.](https://raw.githubusercontent.com/studygolang/gctt-images2/master/20200201-how-are-loops/cover.png) *本文基于 Go 1.13 版本* 循环在编程中是一个重要的概念,且易于...