Go Vet Analysis and Fix Prompt

Last updated on Feb 27, 2026

A Go vet analysis prompt that runs go vet ./... across your entire codebase, identifies potential issues, and automatically applies fixes. Go vet catches suspicious constructs that the compiler doesn’t flag — like unreachable code, incorrect format strings in Printf, misuse of sync primitives, and struct tag errors.

The agent follows a fix-and-verify loop: it runs go vet, fixes every reported issue with an explanation, then re-runs to confirm a clean pass. You get a structured report with the initial findings, each fix with before/after code, and final verification. For deeper analysis beyond what go vet covers, pair this with the staticcheck prompt.

Prompt

You are an AI assistant tasked with analyzing and fixing issues in a Go codebase using the `go vet` tool. Follow these instructions carefully to complete the task:

1. First, you will be provided with a Go codebase to analyze. It will be in the directory you are currently in.

2. Run the `go vet` command on the entire codebase using the following command:

<command>
go vet ./...
</command>

Analyze the output of this command to identify any potential issues.

3. For each issue identified by `go vet`:
a. Describe the issue in detail.
b. Explain the potential problems it could cause.
c. Provide a fix for the issue, including the modified code.

4. After implementing all fixes, run `go vet ./...` again to verify that all issues have been resolved.

5. Prepare a report of your findings and actions. Your report should include:
a. A list of all issues initially identified by `go vet`.
b. A description of each fix implemented, including the original problematic code and the fixed code.
c. The results of the final `go vet` run, confirming that all issues have been resolved.

6. If no issues were found in the initial `go vet` run, or if all issues were successfully fixed, explicitly state that the code now passes all `go vet` checks.

Format your final output as follows:

<go_vet_report>
<title>
[Count of issues and title]
</title>
<initial_issues>
[List all issues initially identified by go vet and where]
</initial_issues>

<fixes_implemented>
[For each issue, provide:
- Description of the issue
- Original problematic code
- Fixed code
- Explanation of the fix]
</fixes_implemented>

<final_result>
[Report the result of the final go vet run, confirming all issues are resolved or that no issues were found]
</final_result>
</go_vet_report>

Remember, your final output should only include the content within the <go_vet_report> tags. Do not include any of your thought process or intermediate steps in the final output.

Subscribe for the latest prompts

Get the latest prompts delivered to your inbox