Home > Backend Development > Golang > Run godoc Automatically

Run godoc Automatically

Barbara Streisand
Release: 2024-11-30 14:56:10
Original
435 people have browsed it

Run godoc Automatically

VSCode has a fantastic task runner, with lots of configuration options for when and how the task should be run.

Let's set up godoc to run whenever you open the project. It will display a push notification linking you to godoc server within your browser.

STEPS to Add

(1) Install godoc via your terminal

 go install golang.org/x/tools/cmd/godoc@latest
Copy after login

(2) Add the task with CTRL-SHIFT-P, "Configure Tasks" . This edits ./vscode/tasks.json
(3) Add the following task to the tasks array (copy the individual task object below)

{
    // 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": []
        }
    ]
}
Copy after login

(4) Run the task. You can run the task with CTRL-SHIFT-P → "Run Task" → "godoc" or by reopening your window. A notice will show linking you to godoc. Or you can find the link using the "Ports" tab and clicking the godoc URL.

The above is the detailed content of Run godoc Automatically. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template