docs(note): reorganize notes structure and migrate content

- Move Windows and 算法 notes from 随手记 to 资源 directory
- Migrate Golang map pitfalls and dot import notes to Golang/使用注意
- Delete omos配置 note
- Add Typora custom theme reference link
This commit is contained in:
张育新 2026-07-15 19:12:07 +08:00
parent e00245ea66
commit e486d47e2a
6 changed files with 54 additions and 226 deletions

View File

@ -14,4 +14,5 @@
### 拖拽到终端
- 直接把文件**拖入** PowerShell 或 CMD 窗口,会自动粘贴完整路径。
- 直接把文件**拖入** PowerShell 或 CMD 窗口,会自动粘贴完整路径。

View File

@ -210,3 +210,54 @@ func TestJson(t *testing.T) {
1. **小请求配置、JSON**:使用 `io.ReadAll` 存入内存,再通过 `io.NopCloser` 塞回 `r.Body` 或设置 `r.GetBody`
2. **中等请求(签名校验)**:使用 `io.TeeReader` 边读边处理,节省一次全量扫描。
3. **大请求(文件上传)****禁止 ReadAll**。直接流式 `io.Copy` 到目的地,或使用临时文件做中转。
## map的坑
go的map内部是哈希表元素会因 rehash扩容而移动到新的内存位置如果允许 `&m[key]` 拿到一个指针map 一旦扩容,这个指针就变成悬空指针(指向已失效的内存),为了避免这种内存安全问题Go 直接禁止对 map 值取地址,下面是示例代码:
```go
type User struct {
Name string
Age int
}
func main() {
m := map[int]User{1: {Name: "张三", Age: 20}}
// ❌ 编译错误cannot assign to struct field m[1].Name in map
m[1].Name = "李四"
// ✅ 正确的替代写法
temp:=m[1]
temp.Name = "李四"
m[1]=temp
}
```
> **可寻址addressable**:能通过 `&` 拿到它内存地址的操作数。
>
> **不可寻址not addressable**:不能通过 `&` 拿到地址的操作数。
## 句点引入
一个完整引入声明语句形式的引入名`importname`可以是一个句点(`.`)。 这样的引入称为句点引入。使用被句点引入的包中的导出代码要素时,限定标识符的前缀必须省略。
比如在下面这个例子中,`Println`和`Now`函数调用不需要带任何前缀。
```go
package main
import (
. "fmt"
. "time"
)
func main() {
Println("Current time:", Now())
}
```
> 一般来说,句点引入不推荐使用,因为它们会导致较低的代码可读性

View File

@ -1,50 +1 @@
## 句点引入
一个完整引入声明语句形式的引入名`importname`可以是一个句点(`.`)。 这样的引入称为句点引入。使用被句点引入的包中的导出代码要素时,限定标识符的前缀必须省略。
比如在下面这个例子中,`Println`和`Now`函数调用不需要带任何前缀。
```go
package main
import (
. "fmt"
. "time"
)
func main() {
Println("Current time:", Now())
}
```
> 一般来说,句点引入不推荐使用,因为它们会导致较低的代码可读性
## map的坑
go的map内部是哈希表元素会因 rehash扩容而移动到新的内存位置如果允许 `&m[key]` 拿到一个指针map 一旦扩容,这个指针就变成悬空指针(指向已失效的内存),为了避免这种内存安全问题Go 直接禁止对 map 值取地址,下面是示例代码:
```go
type User struct {
Name string
Age int
}
func main() {
m := map[int]User{1: {Name: "张三", Age: 20}}
// ❌ 编译错误cannot assign to struct field m[1].Name in map
m[1].Name = "李四"
// ✅ 正确的替代写法
temp:=m[1]
temp.Name = "李四"
m[1]=temp
}
```
> **可寻址addressable**:能通过 `&` 拿到它内存地址的操作数。
>
> **不可寻址not addressable**:不能通过 `&` 拿到地址的操作数。

View File

@ -1,176 +0,0 @@
```json
{
"$schema": "https://unpkg.com/oh-my-opencode-slim@latest/oh-my-opencode-slim.schema.json",
"preset": "zhipu",
"presets": {
"opencode-go": {
"orchestrator": {
"model": "opencode-go/glm-5.2",
"skills": [
"*"
],
"mcps": [
"*",
"!context7"
]
},
"oracle": {
"model": "deepseek/deepseek-v4-pro",
"variant": "max",
"skills": [
"simplify"
],
"mcps": []
},
"council": {
"model": "opencode-go/qwen3.7-max",
"variant": "high",
"skills": [],
"mcps": []
},
"librarian": {
"model": "opencode-go/minimax-m3",
"skills": [],
"mcps": [
"websearch",
"context7",
"gh_grep"
]
},
"explorer": {
"model": "opencode-go/mimo-v2.5-pro",
"skills": [],
"mcps": []
},
"designer": {
"model": "opencode-go/kimi-k2.7-code",
"variant": "medium",
"skills": [],
"mcps": []
},
"fixer": {
"model": "opencode-go/deepseek-v4-flash",
"variant": "high",
"skills": [],
"mcps": []
},
"observer": {
"model": "opencode-go/kimi-k2.7-code",
"skills": [],
"mcps": []
}
},
"zhipu": {
"orchestrator": {
"model": "zhipuai-coding-plan/glm-5.2",
"skills": [
"*"
],
"mcps": [
"*",
"!context7"
]
},
"oracle": {
"model": "zhipuai-coding-plan/glm-5.2",
"variant": "max",
"skills": [
"simplify"
],
"mcps": []
},
"council": {
"model": "zhipuai-coding-plan/glm-5.1",
"skills": [],
"mcps": []
},
"librarian": {
"model": "zhipuai-coding-plan/glm-5-turbo",
"skills": [],
"mcps": [
"websearch",
"context7",
"gh_grep"
]
},
"explorer": {
"model": "zhipuai-coding-plan/glm-5-turbo",
"skills": [],
"mcps": []
},
"designer": {
"model": "zhipuai-coding-plan/glm-5.2",
"variant": "medium",
"skills": [],
"mcps": []
},
"fixer": {
"model": "zhipuai-coding-plan/glm-5.2",
"skills": [],
"mcps": []
},
"observer": {
"model": "zhipuai-coding-plan/glm-4.6v",
"skills": [],
"mcps": []
}
},
"deepseek": {
"orchestrator": {
"model": "deepseek/deepseek-v4-pro",
"variant": "high",
"skills": [
"*"
],
"mcps": [
"*",
"!context7"
]
},
"oracle": {
"model": "deepseek/deepseek-v4-pro",
"variant": "max",
"skills": [
"simplify"
],
"mcps": []
},
"council": {
"model": "deepseek/deepseek-v4-pro",
"variant": "medium",
"skills": [],
"mcps": []
},
"librarian": {
"model": "deepseek/deepseek-v4-flash",
"skills": [],
"mcps": [
"websearch",
"context7",
"gh_grep"
]
},
"explorer": {
"model": "deepseek/deepseek-v4-flash",
"skills": [],
"mcps": []
},
"designer": {
"model": "deepseek/deepseek-v4-pro",
"variant": "medium",
"skills": [],
"mcps": []
},
"fixer": {
"model": "deepseek/deepseek-v4-flash",
"variant": "high",
"skills": [],
"mcps": []
}
}
},
"disabled_agents": []
}
```

View File

@ -2,3 +2,4 @@
[Typora自定义主题](https://theme.typora.io/doc/zh/Write-Custom-Theme/)