0%

golang_ide_goland使用

1. 操作

1. 1 自动格式化和导入包

go fmt + go imports

go to preferences ->Tools ->File Watchers and enable go fmt . This way on each save it will format the file.

goland tools->filewatchers->go fmt| go imports

1.2 快捷键

  • 删除行 cmd + x

  • 复制行 cmd + d

  • 进入返回函数 cmd + []

1.3 文件

  • 快速搜索文件名字: 两次 shift

  • 比较文件: 选择两个文件 cmd+d, 方便比较json

  • 文件导航 cmd + 7 折叠, 展开,设置,隐藏

    按导出排序(建议), 按字母排序(建议), 私有函数(建议), 非当前文件的属性(不建议)

  • 呼出最近文件和常用功能 cmd + E , favorites 可以查看书签/断点/收藏

1.4 代码

  • 查看struct实现了哪些接口 cmd + u
  • interface查看实现的Struct的列表 ctrl + h

2. 错误

2.1 Cannot resolve symbol

鼠标在报错地方, 弹出提示,sync即可解决。

2.2 导入包错误

1
2
3
4
5
6
7
8
9
10
11
1. export GOINSECURE="gitlab.staff.funlink-tech.com",GOPRIVATE="gitlab.staff.funlink-tech.com"

2. vi ~/.gitconfig, 遇到 http 请求,走 ssh 方式, 因为 go get 它是以 https 的方式去获取依赖,而且默认是 http 协议去下载的


[url "git@gitlab.staff.funlink-tech.com:"]
insteadOf = https://gitlab.staff.funlink-tech.com/

3. 清理 go 的 mod cache

4. goland 找出红色的小灯泡,sync
给作者打赏,可以加首页微信,咨询作者相关问题!