We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f7d28b0 commit f670213Copy full SHA for f670213
_posts/2024-02-27-go.md
@@ -7,8 +7,32 @@ last_modified_at:
7
pin: false
8
---
9
10
-## 基本语法
+# 基本语法
11
+
12
+变量初始化:
13
14
```go
15
+var s string = "string"
16
+var s = "string"
17
s := "string"
-```
18
+```
19
20
+变量自增:只有后缀自增或自减,并且必须单独一行。
21
22
+条件判断语句中的初始变量可以在布尔表达式里,并且不能使用0/1作为判断条件
23
+```go
24
+if cond := true; cond {
25
+ fmt.Println()
26
+}
27
28
29
+# 知识点
30
31
+## 数组和切片
32
33
+- 数组在内存中是一段连续的内存空间,元素的类型和长度都是固定的;
34
+- 切片在内存中由一个指向底层数组的指针、长度和容量组成的,长度表示当前包含的元素个数,容量表示切片可以拓展的最大元素个数。切片 `s[x: y]` 表示 `s` 中第 `x` 位到第 `y - 1` 位元素截取。
35
36
+## 协程
37
38
+简而言之:用户态的线程
0 commit comments