Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Go 实现/定义跳转New to Visual Studio Code? Get it now.
Go 实现/定义跳转

Go 实现/定义跳转

amliu

|
1 install
| (0) | Free
类似 GoLand:在接口/方法旁显示箭头,快速跳转到定义或实现
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Go 实现/定义跳转

English documentation follows the Chinese version below.

类似 GoLand:在接口、结构体和方法旁显示绿色箭头,快速跳转到实现或定义/接口。

效果

  • 接口 / 接口方法:↓,跳转到所有实现
  • 结构体方法:↑,跳转到它实现的接口方法
  • 接口类型同时有父接口和实现时:显示上下箭头
  • 箭头颜色可配置(goNavGutter.arrow.color),默认 GoLand 绿 #59A869
  • 可选:符号右侧显示可点击的 N implementations(goNavGutter.inlayHint.enabled,默认关闭)
  • 点击后弹出与 GoLand 类似的列表(类型名 + 包路径),选中即跳转

依赖当前工作区已安装的语言服务(Go 需要 Go 插件 + gopls)。

箭头位置

VS Code 扩展 API 只有一条真正的 gutter 车道 —— 行号左侧的断点栏(glyph margin),位置不可调、也不能新增车道。想画在别处只能借用正文区域,于是有了两种取舍:

goNavGutter.arrow.position 位置 可点击 副作用
glyphMargin(默认) 行号左侧,不随横向滚动 否,点击被断点接走 同行有断点时 gutter 加宽一列
afterName 符号名右侧 是,判定精确 本行后续内容右移,随正文滚动
hidden 不画箭头 — 只保留悬停链接、右键菜单和快捷键

glyphMargin 下跳转走悬停链接、行尾提示和快捷键。afterName 下箭头是锚在符号名末尾的内容装饰,点它时光标正好落到这个位置,插件据此识别点击并打开跳转列表。

glyph margin 分 Left / Center / Right 三条车道:扩展装饰默认落在 Center,断点固定在 Right。所以同一行既有断点又有箭头时两者并排显示(箭头在左、断点在右),gutter 会为此加宽一条车道,不存在互相覆盖。只有和别的扩展的 gutter 图标撞在 Center 时才会挤在同一格。

安装

在 VS Code 扩展面板搜索 Go 实现/定义跳转,或命令行:

code --install-extension amliu.go-nav-gutter

用法

操作 说明
悬停方法名,点链接 打开跳转列表
点击行尾 N implementations 打开实现列表并跳转
右键箭头或行号 「跳转到实现」/「跳转到定义/接口」,作用于被点的那一行
Ctrl+Alt+B(macOS Cmd+Alt+B) 跳转到实现
Ctrl+Alt+U(macOS Cmd+Alt+U) 跳转到定义/接口
Alt+Enter 智能跳转(当前行仅有一个方向时直接打开)
点击箭头 仅 arrow.position: afterName 时可用

只有一处目标时会直接跳转;多处时弹出可搜索列表。

配置

设置界面里分成四组:常规、箭头、其他入口、分析。

常规

配置项 默认 说明
goNavGutter.enabled true 总开关
goNavGutter.languages ["go"] 启用的语言

箭头

配置项 默认 说明
goNavGutter.arrow.position glyphMargin 箭头位置,见上表;hidden 为不显示
goNavGutter.arrow.color #59A869 箭头颜色,可填 CSS 颜色或主题色 id
goNavGutter.arrow.scale 70 相对行高的缩放百分比,仅 glyphMargin
goNavGutter.arrow.margin 4 与两侧代码的间距(px),仅 afterName
goNavGutter.arrow.background rgba(89,168,105,0.22) 背景色,非空时渲染成圆角徽章,仅 afterName
goNavGutter.arrow.shadow 空 阴影,填 CSS box-shadow 的值,仅 afterName
goNavGutter.arrow.clickToNavigate true 点击箭头直接跳转,仅 afterName

其他入口

配置项 默认 说明
goNavGutter.inlayHint.enabled false 符号右侧可点击的 N implementations
goNavGutter.statusBar.enabled false 状态栏快捷入口

分析

配置项 默认 说明
goNavGutter.analysis.debounceMs 400 文件变更后重新分析的防抖时间
goNavGutter.analysis.maxConcurrent 4 查询实现/定义的最大并发数

arrow.color 填 #59A869、green、rgb(89,168,105) 这类值时固定成该颜色,两种位置都生效(glyphMargin 下会按该颜色生成一份 SVG 副本)。填带点号的主题色 id(如 charts.green、editorInfo.foreground)可跟随主题明暗切换,但只在 afterName 下有效,glyphMargin 会退回默认绿。

arrow.scale 只对 glyphMargin 的 SVG 图标生效;afterName 的箭头是字符,大小跟编辑器字体走,间距用 arrow.margin 调。

afterName 默认就是绿色箭头加一层同色系半透明底(arrow.background 非空时会自动补 3px 圆角和左右内边距)。想更醒目可以换成实心底加白箭头:

"goNavGutter.arrow.color": "#ffffff",
"goNavGutter.arrow.background": "#59A869",
"goNavGutter.arrow.shadow": "0 1px 2px rgba(0,0,0,0.45)"

不想要底块就把 arrow.background 设成空字符串。arrow.shadow 用 0 0 0 1px <色> 可以当描边(不像 border 会撑大盒子),用 0 0 6px <色> 是光晕。这两项的值会被拼进 CSS 规则,因此 {}<>; 会被过滤掉。

inlayHint.enabled 默认关闭。打开后会在符号名右侧显示可点击的 N implementations,和箭头落在同一位置,两个都开会略显拥挤。

语言服务尚未就绪时,箭头会在 gopls 启动后自动出现。若没有图标,确认已安装 Go 扩展,并执行命令 Go Nav Gutter: 刷新当前文件导航标记。


Go Implementation / Definition Navigation

GoLand-style navigation for VS Code: green arrows next to interfaces, structs and methods that jump to implementations or definitions/interfaces.

What you get

  • Interface / interface method: ↓, jumps to every implementation
  • Struct method: ↑, jumps to the interface method it implements
  • Interface type with both supertypes and implementations: shows a double arrow
  • Arrow color is configurable (goNavGutter.arrow.color), defaults to GoLand green #59A869
  • Optional clickable N implementations next to the symbol (goNavGutter.inlayHint.enabled, off by default)
  • Picking an entry opens a GoLand-like list (type name + package path) and jumps there

Requires a language server in the current workspace. For Go that means the Go extension plus gopls.

Arrow placement

The VS Code extension API exposes exactly one real gutter lane — the breakpoint column (glyph margin) to the left of the line numbers. Its position is fixed and no extra lane can be added. Drawing anywhere else means borrowing space from the text area, hence the trade-off:

goNavGutter.arrow.position Where Clickable Side effect
glyphMargin (default) Left of the line number, does not scroll horizontally No, clicks are taken by breakpoints Gutter widens by one lane when the line also has a breakpoint
afterName Right after the symbol name Yes, precise hit testing Shifts the rest of the line right, scrolls with the text
hidden No arrow — Only hover links, context menu and keybindings remain

With glyphMargin you navigate via hover links, inlay hints and keybindings. With afterName the arrow is an after decoration anchored to the end of the symbol name, so clicking it places the cursor exactly there and the extension uses that to open the jump list.

The glyph margin has three lanes — Left / Center / Right. Extension decorations land in Center and breakpoints are pinned to Right, so a line with both shows them side by side (arrow left, breakpoint right) and the gutter widens accordingly; they never overlap. Crowding only happens when another extension also draws in Center.

Install

Search for Go 实现/定义跳转 in the Extensions view, or run:

code --install-extension amliu.go-nav-gutter

Usage

Action Result
Hover a method name, click the link Opens the jump list
Click the N implementations hint Opens the implementation list and jumps
Right-click the arrow or the line number "Go to Implementations" / "Go to Definitions", applied to the clicked line
Ctrl+Alt+B (macOS Cmd+Alt+B) Go to implementations
Ctrl+Alt+U (macOS Cmd+Alt+U) Go to definitions/interfaces
Alt+Enter Smart jump (opens directly when the line only has one direction)
Click the arrow Only with arrow.position: afterName

A single target jumps straight there; multiple targets open a searchable list.

Settings

The settings UI splits these into four groups: General, Arrow, Other entry points, Analysis.

General

Setting Default Description
goNavGutter.enabled true Master switch
goNavGutter.languages ["go"] Language ids the feature applies to

Arrow

Setting Default Description
goNavGutter.arrow.position glyphMargin Arrow placement, see the table above; hidden draws nothing
goNavGutter.arrow.color #59A869 Arrow color, a CSS color or a theme color id
goNavGutter.arrow.scale 70 Size relative to line height, in percent; glyphMargin only
goNavGutter.arrow.margin 4 Spacing from surrounding code, in pixels; afterName only
goNavGutter.arrow.background rgba(89,168,105,0.22) Background color, renders a rounded badge when non-empty; afterName only
goNavGutter.arrow.shadow empty Shadow, a CSS box-shadow value; afterName only
goNavGutter.arrow.clickToNavigate true Clicking the arrow opens the jump list; afterName only

Other entry points

Setting Default Description
goNavGutter.inlayHint.enabled false Clickable N implementations after the symbol
goNavGutter.statusBar.enabled false Status bar shortcut for the current line

Analysis

Setting Default Description
goNavGutter.analysis.debounceMs 400 Debounce before re-analyzing after an edit
goNavGutter.analysis.maxConcurrent 4 Max concurrent implementation/definition queries

A plain value in arrow.color such as #59A869, green or rgb(89,168,105) pins the arrow to that color in both placements (glyphMargin generates a recolored copy of the SVG). A dotted theme color id such as charts.green or editorInfo.foreground follows the light/dark theme, but only works with afterName; glyphMargin falls back to the default green.

arrow.scale only affects the glyphMargin SVG. The afterName arrow is a character, so it follows the editor font size and you adjust the spacing with arrow.margin.

afterName renders a green arrow on a translucent badge of the same hue by default (a non-empty arrow.background automatically adds a 3px radius and horizontal padding). For something bolder, use a solid background with a white arrow:

"goNavGutter.arrow.color": "#ffffff",
"goNavGutter.arrow.background": "#59A869",
"goNavGutter.arrow.shadow": "0 1px 2px rgba(0,0,0,0.45)"

Set arrow.background to an empty string to drop the badge. In arrow.shadow, 0 0 0 1px <color> works as an outline (unlike border, it does not grow the box) and 0 0 6px <color> gives a glow. Both values are inlined into a CSS rule, so {}<>; are stripped.

inlayHint.enabled is off by default. Turning it on shows a clickable N implementations right after the symbol name — the same spot as the arrow, so having both can feel crowded.

Arrows appear on their own once gopls has started. If nothing shows up, make sure the Go extension is installed and run the Go Nav Gutter: 刷新当前文件导航标记 command.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft