Skip to content

Commit 21f0612

Browse files
committed
docs: update docs
1 parent 3c1d8fb commit 21f0612

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/.vuepress/theme.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default hopeTheme({
1515

1616
logo: "/logo.svg",
1717

18-
repo: "github.com/suyuan32/GoGuide",
18+
repo: "suyuan32/GoGuide",
1919

2020
docsDir: "src",
2121

src/en/guide/interview/golang/basic/2-medium.md

+13
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ head:
2828

2929
:::
3030

31+
## Map
3132

3233
### Is the traversal of a Map using range ordered or unordered?
3334

@@ -68,4 +69,16 @@ If the value of the map is
6869

6970
::: tip Exclusive for members
7071
[Code combat analysis](https://articles.zsxq.com/id_4w1a11i6xrw0.html)
72+
:::
73+
74+
### Can a panic caused by a map be recovered?
75+
76+
::: details Answer
77+
A panic caused by concurrent read and write operations on a map cannot be recovered. This is because map-related panics are thrown using `runtime.throw()`, which cannot be recovered.
78+
79+
```go
80+
if h.flags&hashWriting != 0 {
81+
throw("concurrent map read and map write")
82+
}
83+
```
7184
:::

src/guide/interview/golang/basic/2-medium.md

+14
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ head:
2929

3030
:::
3131

32+
## Map 相关
33+
3234
### Map 使用 range 遍历时是有序还是无序的?
3335

3436
::: details 答案
@@ -69,3 +71,15 @@ Map 在内部使用哈希算法放置元素,在自动扩容时又会重新计
6971
::: tip 会员专属
7072
[代码实战解析](https://articles.zsxq.com/id_4w1a11i6xrw0.html)
7173
:::
74+
75+
### Map 产生的 panic 异常能被 recover 吗?
76+
77+
::: details 答案
78+
Map 由于并发读写导致的 panic 是不能被 recover 的,因为 Map 的异常使用 `runtime.throw()` 抛出,这类异常不能被 recover。
79+
80+
```go
81+
if h.flags&hashWriting != 0 {
82+
throw("concurrent map read and map write")
83+
}
84+
```
85+
:::

0 commit comments

Comments
 (0)