
vscode 有一个很棒的任务运行器,有很多关于何时以及如何运行任务的配置选项。
让我们将 godoc 设置为在您打开项目时运行。 它将显示一条推送通知,将您链接到浏览器中的 godoc 服务器。
(1) 通过终端安装 godoc
go install golang.org/x/tools/cmd/godoc@latest
(2) 使用 ctrl-shift-p 添加任务,“配置任务”。这将编辑 ./vscode/tasks.json
(3) 将以下任务添加到任务数组中(复制下面的单个任务对象)
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "godoc",
"type": "shell",
"command": "godoc",
"options": {
"cwd": "${workspaceFolder}",
"shell": {
"args": ["-c"],
"executable": "/bin/sh"
}
},
"runOptions": {"runOn": "folderOpen"},
"presentation": {
"echo": true,
"reveal": "never",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": false
},
"problemMatcher": []
}
]
}
(4) 运行任务。 您可以使用 ctrl-shift-p →“运行任务”→“godoc”或重新打开窗口来运行任务。将显示一条通知,将您链接到 godoc。 或者您可以使用“ports”选项卡并单击 godoc url 找到该链接。
以上就是自动运行 godoc的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号