網頁

2023/1/10

Visual Studio Code Go 找出專案中的構造、方法、函式及全域變數 find symbol in project

VS Code找出Go專案目錄下的構造(struct)、方法、函式及全域變數的方式如下。


構造、方法、函式、全域變數在VS Code通稱為Symbol。可以在上方功能列選擇Go -> Go to Symbol in Workspace...開啟搜尋欄,然後在前綴#後輸入要搜尋的symbol名稱。

或macOS按command ⌘ + T;Windows按Ctrl + T輸入要搜尋的symbol名稱即可。





Question

how to find function, struct or method quickly of Go project in Visual Studio Code?

ChatGPT answer

In Visual Studio Code, you can use the Go to Symbol feature to quickly navigate to a specific function, struct, or method in your Go project. Here's how to use it:

  1. Press Ctrl + T (Cmd + T on macOS) to open the Go to Symbol search bar.

  2. Start typing the name of the symbol you're looking for. The search bar will automatically filter the symbols in your project as you type, making it easy to find the one you're looking for.

  3. Press Enter or click on the symbol you want to navigate to in the search results to go to its definition in the code.

Alternatively, you can use the Outline view which can show a file and package's symbols. Go to View > Outline

If you are using an extension, like Go to Symbol in Project or Go to symbol by name you can use the shortcut it provides. And you can customize the shortcut keys in the settings of vscode.

沒有留言:

張貼留言