Skip to content

Commit f670213

Browse files
linzeCompetitiveLin
authored andcommittedMar 5, 2024
20240305
1 parent f7d28b0 commit f670213

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed
 

‎_posts/2024-02-27-go.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,32 @@ last_modified_at:
77
pin: false
88
---
99

10-
## 基本语法
10+
# 基本语法
11+
12+
变量初始化:
1113

1214
```go
15+
var s string = "string"
16+
var s = "string"
1317
s := "string"
14-
```
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

Comments
 (0)