Skip to content

GoLand

在项目所有文件中查找: shift + command + f

按文件名查找文件: 按两次 shift

查看接口在哪些地方使用过:
右键 -> Find Usages

格式化文件:
左上角工具栏 -> Tools -> Go Tools -> Go Fmt File

插件

GitToolBox: 类似 vscode gitlens 效果

主题插件:
GitHub Theme
https://github.com/primer/github-vscode-theme

快捷键

option + command + 鼠标点击: 跳转代码实现

command + [ 快速回退到上一次跳转的地方

Staticcheck

https://www.phillipsj.net/posts/enabling-staticcheck-in-goland/

格式化

go 文件

Preferences -> Tools -> File Watchers -> + go fmt, use default -> reload goland, agree use go fmt

proto 文件

1
2
brew install clang-format
which clang-format

Install Protocol Buffers plugin

Preferences -> Tools -> File Watchers → + Custom

1
2
3
4
5
Name: proto-fmt
File Type: Protocol Buffer
Scope: Project Files
Program: /usr/local/bin/clang-format
Arguments: -style="{BasedOnStyle: Google, IndentWidth: 2, ColumnLimit: 120, AlignConsecutiveAssignments: true}" -i $FilePath$

then reload goland

Alternatively, you can run the command on the terminal also:

/usr/local/bin/clang-format -style="{BasedOnStyle: Google, IndentWidth: 2, ColumnLimit: 120, AlignConsecutiveAssignments: true}" -i FilePath Example:

Go to /pb folder and mention the .proto file name in this command:

/usr/local/bin/clang-format -style="{BasedOnStyle: Google, IndentWidth: 2, ColumnLimit: 120, AlignConsecutiveAssignments: true}" -i foodpartnerapi.proto