```
docs(pointer): 更新指针教程文档 - 添加了图片引用 - 补充了获取用户输入的代码示例 - 增加了命令行参数解析的完整代码示例 - 完善了指针相关概念说明 ```
This commit is contained in:
parent
93c6350643
commit
8e9bf583c5
29
day01/devcontainer/.devcontainer/devcontainer.json
Normal file
29
day01/devcontainer/.devcontainer/devcontainer.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "Go Dev Container (demo)",
|
||||
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/common-utils:2": {},
|
||||
"ghcr.io/devcontainers/features/go:1": {
|
||||
"version": "1.25"
|
||||
}
|
||||
},
|
||||
"remoteUser": "vscode",
|
||||
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
|
||||
"postCreateCommand": "cd demo && go mod download && go install github.com/go-delve/delve/cmd/dlv@latest",
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": ["golang.go"],
|
||||
"settings": {
|
||||
"go.useLanguageServer": true,
|
||||
"go.toolsManagement.autoUpdate": true,
|
||||
"go.gopath": "/go",
|
||||
"go.testFlags": ["-v"],
|
||||
"go.lintTool": "golangci-lint",
|
||||
"go.lintFlags": ["--fast"],
|
||||
"[go]": {
|
||||
"editor.formatOnSave": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
24
day01/devcontainer/.vscode/launch.json
vendored
Normal file
24
day01/devcontainer/.vscode/launch.json
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launch.json",
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug demo/main.go",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "auto",
|
||||
"program": "${workspaceFolder}/demo",
|
||||
"cwd": "${workspaceFolder}/demo",
|
||||
"console": "integratedTerminal"
|
||||
},
|
||||
{
|
||||
"name": "Debug demo tests",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "test",
|
||||
"program": "${workspaceFolder}/demo",
|
||||
"cwd": "${workspaceFolder}/demo",
|
||||
"console": "integratedTerminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
31
day01/devcontainer/README.md
Normal file
31
day01/devcontainer/README.md
Normal file
@ -0,0 +1,31 @@
|
||||
## 使用 Dev Container 开发 demo 工程
|
||||
|
||||
此目录下的 `demo/` 是一个 Go 工程。已提供 VS Code Dev Container 配置,支持在容器内进行开发与调试。
|
||||
|
||||
### 快速开始
|
||||
- 前置:本地安装 VS Code 与 Dev Containers 扩展(Microsoft 提供)。
|
||||
- 打开文件夹:在 VS Code 中打开 `day01/devcontainer` 目录。
|
||||
- 重新在容器中打开:命令面板运行 “Dev Containers: Reopen in Container”。
|
||||
- 首次启动会执行依赖下载:`postCreateCommand` 会在 `demo/` 下执行 `go mod download`。
|
||||
- 镜像说明:使用 `mcr.microsoft.com/devcontainers/base:ubuntu`,通过 Dev Containers Feature 安装 Go(版本 1.25)。
|
||||
|
||||
### 容器内开发
|
||||
- 代码位置:`/workspaces/<当前打开的文件夹>/demo`。
|
||||
- 常用操作:
|
||||
- 运行:在容器终端进入 `demo/` 目录后执行 `go run main.go`
|
||||
- 构建:`go build`
|
||||
- 测试:`go test ./...`
|
||||
- 已安装:Go 工具链与 VS Code Go 扩展;保存时自动格式化与常用 lint 设置。
|
||||
|
||||
### 调试
|
||||
- 已自动安装 Delve(`dlv`)。
|
||||
- VS Code 已提供调试配置:[day01/devcontainer/.vscode/launch.json](day01/devcontainer/.vscode/launch.json)
|
||||
- 直接在 “Run and Debug” 视图选择 “Debug demo/main.go” 或 “Debug demo tests”。
|
||||
- 断点与变量查看可在容器内正常使用。
|
||||
|
||||
### 备注
|
||||
- 如需额外工具(如 `golangci-lint` 的安装或 `dlv` 调试器),可在 `.devcontainer/devcontainer.json` 中增加特性或 `postCreateCommand`。
|
||||
|
||||
# devcontainer demo 工程
|
||||
|
||||
针对简单场景: 直接用 git bash 做完 vscode的命令工具 来使用
|
||||
3
day01/devcontainer/demo/go.mod
Normal file
3
day01/devcontainer/demo/go.mod
Normal file
@ -0,0 +1,3 @@
|
||||
module demo
|
||||
|
||||
go 1.25.5
|
||||
5
day01/devcontainer/demo/main.go
Normal file
5
day01/devcontainer/demo/main.go
Normal file
@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
println("Hello, World!")
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user