Skip to content

Commit

Permalink
docs: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
suyuan32 committed May 22, 2024
1 parent 3c1d8fb commit 21f0612
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/.vuepress/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default hopeTheme({

logo: "/logo.svg",

repo: "github.com/suyuan32/GoGuide",
repo: "suyuan32/GoGuide",

docsDir: "src",

Expand Down
13 changes: 13 additions & 0 deletions src/en/guide/interview/golang/basic/2-medium.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ head:

:::

## Map

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

Expand Down Expand Up @@ -68,4 +69,16 @@ If the value of the map is

::: tip Exclusive for members
[Code combat analysis](https://articles.zsxq.com/id_4w1a11i6xrw0.html)
:::

### Can a panic caused by a map be recovered?

::: details Answer
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.

```go
if h.flags&hashWriting != 0 {
throw("concurrent map read and map write")
}
```
:::
14 changes: 14 additions & 0 deletions src/guide/interview/golang/basic/2-medium.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ head:

:::

## Map 相关

### Map 使用 range 遍历时是有序还是无序的?

::: details 答案
Expand Down Expand Up @@ -69,3 +71,15 @@ Map 在内部使用哈希算法放置元素,在自动扩容时又会重新计
::: tip 会员专属
[代码实战解析](https://articles.zsxq.com/id_4w1a11i6xrw0.html)
:::

### Map 产生的 panic 异常能被 recover 吗?

::: details 答案
Map 由于并发读写导致的 panic 是不能被 recover 的,因为 Map 的异常使用 `runtime.throw()` 抛出,这类异常不能被 recover。

```go
if h.flags&hashWriting != 0 {
throw("concurrent map read and map write")
}
```
:::

0 comments on commit 21f0612

Please sign in to comment.