IntelliJ idea配置Go开发环境

IntelliJ idea一个月,甚得我心,终弃Sublime、liteIDE。

IntelliJ idea是非常强大的一款IDE,支持丰富的插件。安装配置都是非常简单的,这里不多赘述,主要需要安装两个插件Go和File Watcher,可以安装Markdown的插件,便于读写Markdown文件。

1. 安装插件

  • 点击左上角”File->Settings->Plugins”

《IntelliJ idea配置Go开发环境》 Browse Repository

  • 搜索插件

《IntelliJ idea配置Go开发环境》 Seach Plugin

  • 本地插件安装
    也可以下载插件包,导入到IDEA,效果是一样的

《IntelliJ idea配置Go开发环境》 Local Plugin

插件安装成功之后,重启IDEA。

设置go sdk

《IntelliJ idea配置Go开发环境》 添加go sdk
《IntelliJ idea配置Go开发环境》 Project sdk

  • 配置File watcher
    File Watchers 是工程级别的设置,所以要在上一步工程的基础上操作
    File -> Settings… -> Tools -> File Watchers

go get golang.org/x/tools/cmd/goimports
go get -u github.com/golang/lint/golint

  • goimport

    《IntelliJ idea配置Go开发环境》 go import

-w $FilePath$

  • golint

《IntelliJ idea配置Go开发环境》 image.png

-set_exit_status $FilePath$

  • 导出File Watcher配置,保存在根目录下

    《IntelliJ idea配置Go开发环境》 导处配置

以后新建工程,直接导入该配置,避免重复配置;

2. 配置SDK

《IntelliJ idea配置Go开发环境》 image.png

3.IDEA 的一些设置

从 File -> Settings… 打开设置窗口

0)快捷键(使用eclipse快捷键)

《IntelliJ idea配置Go开发环境》 image.png

  1. 不打开上次工程
    Appearance & Behavior -> System Settings
    去掉 Startup/Shutdown -> Reopen last project on startup

  2. 退出时不需确认
    Appearance & Behavior -> System Settings
    去掉 Startup/Shutdown -> Confirm application exit

  3. 去掉拼写检查
    Editor -> Inspections
    去掉 Spelling -> Typo

  4. 显示行号
    Editor -> General -> Appearance
    勾选 Show line numbers

  5. 编辑器字体
    Editor -> Colors & Fonts -> Fonts

  6. 控制台字体
    Editor -> Colors & Fonts -> Console Fonts

  7. 换行符
    Editor > Code Style
    Line Separator (for new files),最好设置为 Unix and OSX(\n)

  8. 缩进格式
    Editor -> Code Style -> Go

  9. 终端
    Tools -> Terminal
    Shell Path 设置为 “C:\Program Files\Git\bin\bash.exe” –login -i
    Git Bash 提供比 cmd.exe 多得多的功能,墙裂建议将终端设置为 Git Bash,开发过程可以在其中执行很多命令!

    原文作者:iCaptain
    原文地址: https://www.jianshu.com/p/f06104bcf861
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞