File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -128,7 +128,7 @@ Go 无法修改值为结构体的map
128
128
129
129
不要并发读写map,可能导致程序崩溃
130
130
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
131
- 如果多个 goroutine 并发对 map 进行读写,必须要同步。
131
+ 如果多个 goroutine 并发对 map 进行读写,必须要同步,否则可能导致进程退出
132
132
133
133
.. code-block :: go
134
134
@@ -137,13 +137,13 @@ Go 无法修改值为结构体的map
137
137
sync.RWMutex
138
138
m map[string]int
139
139
}{m: make(map[string]int)}
140
- counter.RLock()
141
140
141
+ counter.RLock() // locks for reading
142
142
n := counter.m["some_key"]
143
143
counter.RUnlock()
144
144
fmt.Println("some_key:", n)
145
145
146
- counter.Lock()
146
+ counter.Lock() // locks for writing
147
147
counter.m["some_key"]++
148
148
counter.Unlock()
149
149
Original file line number Diff line number Diff line change @@ -222,7 +222,7 @@ MacOS
222
222
brew install rmtrash # npm install -g safe-rm; alias rm='safe-rm'
223
223
224
224
# 增加 terminal 光标移动速度, https://stackoverflow.com/questions/4489885/how-can-i-increase-the-cursor-speed-in-terminal
225
- # defaults write NSGlobalDomain KeyRepeat -int 1
225
+ # defaults write NSGlobalDomain KeyRepeat -int 1
226
226
mac: 系统设置-> 键盘 -> 修改按键重复到最快,重复前延迟最短。可以让光标在终端里移动更快
227
227
228
228
# 如何在文件更新之后自动刷新浏览器,需要首先 pip 安装 when-changed
You can’t perform that action at this time.
0 commit comments