| 1 | --- |
| 2 | title: "Gopls release v0.20.0 (Jul 2025)" |
| 3 | --- |
| 4 | |
| 5 | This release contains a new experimental Model Context Protocol (MCP) |
| 6 | server for gopls, which may be used to integrate a subset of gopls' |
| 7 | features in AI-assisted environments. |
| 8 | |
| 9 | Gopls' documentation is now available on the Go project's website at |
| 10 | https://go.dev/gopls. (This link reflects the latest gopls release; |
| 11 | use https://tip.golang.org/gopls to see docs for the latest commit.) |
| 12 | Unlike Markdown files in GitHub, these pages are crawled by Google's |
| 13 | web search index. |
| 14 | |
| 15 | ## Configuration changes |
| 16 | |
| 17 | This release enables by default the new persistent index of packages |
| 18 | in the module cache. This was first attempted in [v0.19](./v0.19.0.md) but reverted |
| 19 | due to problems that have since been fixed. |
| 20 | |
| 21 | ## Web-based features |
| 22 | |
| 23 | ### "Split package" tool |
| 24 | |
| 25 | The `source.splitPackage` code action opens a web-based tool that |
| 26 | helps you split a package into two or more components whose |
| 27 | dependencies are acyclic. |
| 28 | |
| 29 | To use it, name a set of components, assign each declaration to a |
| 30 | component, then visualize the dependencies among the components |
| 31 | (including whether they form a cycle). |
| 32 | Refresh the page each time you edit your code to see the latest |
| 33 | information. |
| 34 | |
| 35 | <p align="center"><img title="Split package 'fmt'" src="../assets/splitpkg.png" width="600"></p> |
| 36 | |
| 37 | The tool makes it easy to iterate over potential decompositions |
| 38 | until you find one you are happy with. A future version of |
| 39 | the tool will automate the code transformation, but for now |
| 40 | you must do that step by hand. |
| 41 | |
| 42 | |
| 43 | ## Editing features |
| 44 | |
| 45 | ### Model Context Protocol server |
| 46 | |
| 47 | Gopls now includes an experimental built-in server for the Model Context |
| 48 | Protocol (MCP), allowing it to expose a subset of its functionality to |
| 49 | AI assistants in the form of MCP tools. |
| 50 | |
| 51 | See the [documentation](../features/mcp.md) for more information. |
| 52 | |
| 53 | **Caveats:** This is a brand new mode of operation for gopls, and so we're |
| 54 | still experimenting with the best set of tools and instructions to provide. |
| 55 | Please let us know how well it works for you. Also, please be aware that |
| 56 | allowing LLMs to execute operations in your workspace entails additional |
| 57 | security considerations, as discussed in the documentation above. |
| 58 | |
| 59 | ## Analysis features |
| 60 | |
| 61 | ### `ignoredError` inlay hint |
| 62 | |
| 63 | The new `ignoredError` inlay hint helps catch mistakenly discarded |
| 64 | errors. It inserts an `// ignore error` hint following any statement |
| 65 | that is a function call whose error result is implicitly ignored. For |
| 66 | example, this code: |
| 67 | |
| 68 | ```go |
| 69 | f.Close() |
| 70 | ``` |
| 71 | will appear as: |
| 72 | ```go |
| 73 | f.Close() // ignore error |
| 74 | ``` |
| 75 | |
| 76 | To suppress the hint, write an actual comment containing `ignore |
| 77 | error` following the call statement, or explicitly assign the result |
| 78 | to a blank `_` variable. A handful of common functions such as |
| 79 | `fmt.Println` are excluded from the check. |
| 80 | |
| 81 | Enable it using this configuration: `{"hints": {"ignoredError": true}}`. |
| 82 | |
| 83 | ### `unusedfunc` reports unused `type`, `var`, and `const` declarations too |
| 84 | |
| 85 | <!-- golang/go#40862 --> |
| 86 | |
| 87 | The |
| 88 | [unusedfunc](https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/unusedfunc/) |
| 89 | analyzer now reports any unexported types, variables, and constants |
| 90 | that are unreferenced within their declaring package. |
| 91 | (The problem of unreferenced exported symbols can't be expressed in |
| 92 | the analysis framework since it depends on the entire workspace.) |
| 93 | |
| 94 | ## Code transformation features |
| 95 | |
| 96 | <!-- golang/go#45199 --> |
| 97 | The Rename operation now allows you to rename an embedded field, such |
| 98 | as T in `struct{ T }`, so long as the operation is requested at the |
| 99 | field declaration (T). Both the field and its type will be renamed. |