-
Notifications
You must be signed in to change notification settings - Fork 311
HPNEX-14: feat(golang): rewrite plugin with gopls MCP server and gofmt hook #449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
openshift-merge-bot
merged 2 commits into
openshift-eng:main
from
cblecker:feat/golang-plugin-rewrite
May 6, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "enabledPlugins": { | ||
| "plugin-dev@claude-plugins-official": true, | ||
| "skill-creator@claude-plugins-official": true | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,11 @@ | ||
| { | ||
| "name": "golang", | ||
| "description": "Run golang codebase related commands and tools", | ||
| "version": "0.1.0", | ||
| "description": "Go development tools: gopls MCP server, LSP integration, automatic gofmt formatting, and golangci-lint linting", | ||
| "version": "0.2.0", | ||
| "author": { | ||
| "name": "github.com/openshift-eng" | ||
| } | ||
| } | ||
| }, | ||
| "dependencies": [ | ||
| { "name": "gopls-lsp", "marketplace": "claude-plugins-official" } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "mcpServers": { | ||
| "gopls": { | ||
| "command": "gopls", | ||
| "args": ["mcp"] | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,79 +1,60 @@ | ||
| # Golang Plugin | ||
|
|
||
| A Claude Code plugin for running [golangci-lint](https://golangci-lint.run/) to check and fix code quality issues in Go projects. | ||
|
|
||
| A Claude Code plugin for Go development, providing LSP integration via `gopls` and automatic `gofmt` formatting. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| /plugin install golang@ai-helpers | ||
| ``` | ||
|
|
||
| ## Commands | ||
| ## Features | ||
|
|
||
| | Command | Description | | ||
| |---------|-------------| | ||
| | `/golang:lint-fix` | Run golangci-lint and automatically fix all reported issues | | ||
| ### gopls MCP Server | ||
|
|
||
| ## Skills | ||
| Integrates the `gopls` language server as an MCP server, providing Go-aware code intelligence including go-to-definition, find references, hover documentation, and workspace symbols. | ||
|
|
||
| ### Automatic gofmt Formatting | ||
|
|
||
| A PostToolUse hook automatically runs `gofmt -w -s` on any `.go` file after it is written or edited, keeping code consistently formatted without manual intervention. | ||
|
|
||
| ### LSP Integration (via dependency) | ||
|
|
||
| | Skill | Description | | ||
| |-------|-------------| | ||
| | Go Lint | Detects and runs golangci-lint using the best available method for the repository. Loaded automatically when linting is relevant, and used by both commands above. | | ||
| Depends on the `gopls-lsp` plugin from `claude-plugins-official`, which enables LSP-based operations for Go code navigation and analysis. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - go compiler (available in $PATH) | ||
| - Go toolchain with `gopls` and `gofmt` available in `$PATH` | ||
| - `golangci-lint` available in `$PATH` (required by the `golang:lint` and `golang:lint-fix` skills) | ||
|
|
||
| - **Optional**: `make lint` target configured in Makefile, if not present the command will run `golangci-lint` directly. | ||
| Install `gopls` if not already present: | ||
|
|
||
| ## Recommended Permissions | ||
| ```bash | ||
| go install golang.org/x/tools/gopls@latest | ||
| ``` | ||
|
|
||
| To allow Claude Code to run the linter commands without prompting for approval, add the following to your project's `.claude/settings.json`: | ||
| Install `golangci-lint` if not already present: | ||
|
|
||
| ```json | ||
| { | ||
| "permissions": { | ||
| "allow": [ | ||
| "Bash(curl -s https://api.github.com/repos/golangci/golangci-lint/releases/latest)", | ||
| "Bash(make golangci-lint:*)", | ||
| "Bash(./bin/golangci-lint:*)", | ||
| "Bash(GOBIN=/tmp go install:*)", | ||
| "Bash(/tmp/golangci-lint:*)", | ||
| "Bash(make lint:*)", | ||
| "Bash(make lint)" | ||
| ] | ||
| } | ||
| } | ||
| ```bash | ||
| go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest | ||
| ``` | ||
|
|
||
| ### What these permissions allow: | ||
| ## Skills | ||
|
|
||
| ### `golang:lint` | ||
|
|
||
| | Permission | Purpose | | ||
| |------------|---------| | ||
| | `curl ... golangci-lint/releases/latest` | Check for latest golangci-lint version | | ||
| | `make golangci-lint:*` | Run make targets for golangci-lint installation | | ||
| | `./bin/golangci-lint:*` | Run golangci-lint from project's bin directory | | ||
| | `GOBIN=/tmp go install:*` | Install golangci-lint to /tmp for temporary use | | ||
| | `/tmp/golangci-lint:*` | Run golangci-lint from /tmp | | ||
| | `make lint:*`, `make lint` | Run the standard `make lint` target | | ||
| Runs `golangci-lint` to check Go code quality. Discovers the lint command via CLAUDE.md/AGENTS.md, Makefile targets (`lint`, `verify-lint`), or direct `golangci-lint run ./...` invocation. Reports total issue count, breakdown by linter, and examples. Read-only — never modifies files. | ||
|
|
||
| ## Usage | ||
| Invoked automatically when linting is appropriate (e.g., before committing Go changes), or on demand. | ||
|
|
||
| ### `/golang:lint`: check for linter issues | ||
| ### `golang:lint-fix` | ||
|
|
||
| This will: | ||
| 1. Run golangci-lint using available methods (via the "Go Lint" skill) | ||
| 2. Report total number of issues found | ||
| 3. Summarize issues by category (goconst, gocyclo, staticcheck, etc.) | ||
| 4. Show example issues | ||
| Runs `golangci-lint --fix` to auto-fix issues, then uses AI to resolve any remaining ones iteratively until the output is clean. Uses the same discovery cascade as `golang:lint`. | ||
|
|
||
| The "Go Lint" skill is also loaded automatically when the agent detects that linting is needed (e.g., the user says "run the linter" or "check for lint issues"). | ||
| User-invocable only (`/golang:lint-fix`) — not triggered automatically due to its destructive nature. | ||
|
|
||
| ### `/golang:lint-fix`: check for linter issues and fix them | ||
| ## Dependencies | ||
|
|
||
| This will: | ||
| 1. Run the "Go Lint" skill to identify all issues | ||
| 2. Systematically fix each category of issues | ||
| 3. Re-run linter after each fix to verify | ||
| 4. Continue until all issues are resolved | ||
| | Plugin | Marketplace | Purpose | | ||
| |--------|-------------|---------| | ||
| | `gopls-lsp` | `claude-plugins-official` | LSP integration for Go code intelligence | | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| { | ||
| "description": "Auto-format Go files with gofmt after write/edit", | ||
| "hooks": { | ||
| "PostToolUse": [ | ||
| { | ||
| "matcher": "Write", | ||
| "hooks": [ | ||
| { | ||
| "type": "command", | ||
| "if": "Write(**/*.go)", | ||
| "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/gofmt.sh", | ||
| "timeout": 10 | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "matcher": "Edit", | ||
| "hooks": [ | ||
| { | ||
| "type": "command", | ||
| "if": "Edit(**/*.go)", | ||
| "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/gofmt.sh", | ||
| "timeout": 10 | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.