golang Quick Start [6.1] - Detailed Integrated Development Environment -goland

preamble

Foreword

  • In the previous article, we made an exposition of the basic principles of language go, this article will introduce the go language integrated development environment golandinstallation, configuration, activation, and basic usage of shortcut keys.

  • For a mature developer, we are committed to using the most convenient and efficient development tools to accelerate the writing and debugging programs go. IDE (Integrated Development Environment, referred to as IDE) is an auxiliary application developers to develop software applications in-house developed tools can assist with writing the source text, and packaged into compiled programs are available, and some can even design graphics interface . IDE typically includes a programming language editors, automated build tools, typically includes a debugger.

  • Most integrated development environments against one of the characteristics of language, goland JetBrains is a cross-platform development for the go language IDE. Support windows, macOS with Ubuntu platform. Because the focus, so professional, goland provides strong support for the program go.

Integrated Development Environment to consider the selection of elements

  • Syntax highlighting is essential to the function, which is why every development tools provide configuration file to implement custom configuration of the reason.

  • Has a good overview of project files and navigation capabilities, you can edit multiple source files and set bookmarks, can match brackets can jump to a function or type definition section.

  • Perfect find and replace function, before replacing the best can preview the results.

  • When there is a compilation error, double-click the error to jump to where the error occurred.

  • 跨平台,能够在 Linux、Mac OS X 和 Windows 下工作,这样就可以专注于一个开发环境。

  • 能够通过插件架构来轻易扩展和替换某个功能。

  • 拥有断点、检查变量值、单步执行、逐过程执行标识库中代码的能力。

  • 能够方便的存取最近使用过的文件或项目。

  • 拥有对包、类型、变量、函数和方法的智能代码补全的功能。

  • 能够方便地在不同的 Go 环境之间切换。

  • 针对一些特定的项目有项目模板,如:Web 应用,App Engine 项目,从而能够更快地开始开发工作

安装goland

  • goland支持windows、macOS与Ubuntu平台,下面我们以windows平台为例为大家介绍安装goland 2019.3,其他平台安装类似

  • 首先进入goland官网,点击下载,安装最新版goland

v2-b173c3769163ff2387d1c83bb1e7dd6a_1440w.jpg

  • 点击下一步

v2-788ae9db3e14f5fb11a9ad492b9b5b24_1440w.jpg

  • 择安装路径、默认即可,选择下一步

v2-46b198487340f99889aea9c52ab18cf1_1440w.jpg

  • 安装配置选项,勾选添加桌面图标以及与.go文件关联即可

v2-1ac2eaa78ad129b74626ae0fa364f066_1440w.jpg

  • 选择开始菜单文件夹,默认即可,点击insall 进行安装

  • 安装完成后,点击finish,运行goland

v2-b63973941e35b50b2c06a6ec464ad155_1440w.jpg

第一次打开goland

  • 在一开始打开goland时,由于没有任何已有配置,我们选择don't import settings

v2-d99cdc228379f0632f88251e50f73875_1440w.jpg

  • 确认接受同意协议,你懂的~

v2-8c3a400dac1352b0af2b8b42c38d160c_1440w.jpg

  • 发送反馈,选择don't send

v2-4db52c2721399bf688be47c31b29f904_1440w.jpg

  • 选择UI背景,程序员一般选择黑色,眼神不好可以选择白色,跳过其他设置

goland的激活

  • 任何用户可以免费获取30天的试用

  • 第一种是方式土豪:goland的激活目前有多种方式,直接会到官网进行购买,199美元一年

  • 第二种方式:对于学生可以免费申请。申请地址

  • 第三种方式:安装破解版goland、这种方式不是很好,因为无法享受更新

  • 第四种方式:特殊渠道如淘宝购买,只需要几块钱

  • 第五种方式:后台留言获取激活码~

第一次使用

  • 选择新建一个项目

v2-5007272dacf96ae35578e4661d4977ad_1440w.jpg

  • 修改项目名,点击创建

v2-e70a4aba2eda24642f4cfab46d32d5d3_1440w.jpg

  • 点击文件夹,右键,创建一个main.go文件

v2-6919cc416789b7071ab9defd9d359407_1440w.jpg

goland 整体视图

v2-a05d514e857335395864d74c6d05df88_1440w.jpg

  • 如上图,最上方为工具栏,可以修改,创建,搜索,删除,替换,修改视图,跳转,运行,调试等多种功能

  • 最左边为项目的目录树结构、依赖等

  • 右边为编辑代码的地方

  • 最下边也有各种终端todo工具栏,以及状态栏

goland 配置

  • goland配置可以点击最上方"file->setiing",一开始配置得最多的是goroot,gopath,字体大小与颜色

  • gorootgopathgomodule等概念后面笔者会详细介绍,goland默认会使用环境变量中的gorootgopath路径

v2-f200351d9e4a0c3b703b154c2f5d6138_1440w.jpg

  • 还有很多对数据库的支持,git的集成工具等,在本文中暂时不做介绍

goland 书写第一个helloworld程序

  • 当我们书写一个最简单的helloworld程序时,当我们输入fmt.,会看到goland会智能的显示出fmt包中的函数。当完成函数编写时,会自动的导入fmt包,import "fmt"这是goland强大功能的一个体现。

v2-5d3df782f9f342af7ab8728cd418c3fb_1440w.jpg

  • 当代码写好之后,运行代码有多种方式

    • 第一种,点击上方选项卡`Run -> Run`

    • 第二种,使用快捷键,mac下为`shift + option + R`,windows下为`Alt + shift + F10`

    • 第三种,点击`func main()` 左边的绿色箭头

    • 第四种,在最下方到终端中,书写`go run main.go` 并运行


goland 快捷键

  • goland拥有很多快捷键,可以加速我们对于代码的书写.下面我们介绍goland分别在windows/ubuntu 与mac下的快捷键使用

  • goland中要查看、修改、查找所有的快捷键,可以在顶部工具栏file-> keymap查看

v2-8f633cb263b6b182041a8ae3ad08df03_1440w.jpg

  • 在使用快捷键的时候,要注意快捷键冲突的问题,例如与搜狗输入法等软件的快捷键冲突

mac下快捷键

Mac 键盘符号和修饰键说明

⌘ ——> Command
⇧ ——> Shift
⌥ ——> Option
⌃ ——> Control
↩︎ ——> Return/Enter
⌫ ——> Delete
⌦ ——> 向前删除键(Fn + Delete)
↑ ——> 上箭头
↓ ——> 下箭头
← ——> 左箭头
→ ——> 右箭头
⇞ ——> Page Up(Fn + ↑)
⇟ ——> Page Down(Fn + ↓)
⇥ ——> 右制表符(Tab键)
⇤ ——> 左制表符(Shift + Tab)
⎋ ——> Escape(Esc)
End ——> Fn + →
Home ——> Fn + ←

Part 1:Editing(编辑)

v2-ee7dad6f08243a67d4ecb5572b79ad45_1440w.jpgv2-e0d1d0b5841c7e0523c479496262eb0d_1440w.jpgv2-d6a54873daa8e852f6e963ae755b0ae4_1440w.jpg

Part 2:Search / Replace(查询/替换)

v2-a056d0aa325b96e72c19eb6c76ab9749_1440w.jpg

Part 3:Usage Search(使用查询)

v2-25b5567e32022f41dbce6b5f84f88c99_1440w.jpg

Part 4:Compile and Run(编译和运行)

v2-ca79120da4604cf1663e963f8cfde3e0_1440w.jpg

Part 5:Debugging(调试)

v2-f05f0ab480d1be683c07b469b55c2e38_1440w.jpg

Part 6:Navigation(导航)

v2-54eca02b87f92708ae6100f3f1696ca5_1440w.jpgv2-b8f4265f05cfc7ea31e4b4e64556cbf0_1440w.jpg

Part 7:Refactoring(重构)

v2-7a903ebc925bd9ac27bcd6813fad0d4e_1440w.jpg

Part 8:VCS / Local History(版本控制 / 本地历史记录)

v2-76be714f23eb37fad7aadadcd1b88382_1440w.jpg

Part 9:Live Templates(动态代码模板)

v2-2825bbe0155c908072fcaf4ca1dba8ef_1440w.jpg

Part 10:General(通用)

v2-67029d8a307bb611b5fb650a19e04090_1440w.jpg

windows下快捷键

Ctrl

v2-c2fbc584f8be2052f62d22892e2f5b6c_1440w.jpgv2-2b05bf3563ee8771b1b0c3d4bac3677a_1440w.jpgv2-682a8eabd8200cf4642b5271482e4566_1440w.jpgv2-700957b4379632bee49c26b0a38d43eb_1440w.jpg

Alt

v2-d87b4ff698000e95c405906b6eec34b4_1440w.jpgv2-3598de4bb299da9aee120eb2902b2a2e_1440w.png

Shift

v2-422b6699e1d71f5b073ec2ddc805e8be_1440w.jpg

Ctrl + Alt

v2-e07597e984785c756f3594bd15bf557b_1440w.jpgv2-10c079f46f2cfafc2fa4fa24a79d4f19_1440w.jpg

Ctrl + Shift

v2-0f9242bd42b84db60ab9c3ee67c560de_1440w.jpgv2-37eaef7ea9f8ca58234d982106f9a758_1440w.jpgv2-4bb8dd7faa5cc7c9e788218a3c81b8ee_1440w.jpg

Alt + Shift

v2-3db5d26fec9a3503135c1a6e3cc88163_1440w.jpg

Ctrl + Shift + Alt

v2-9604696d5e3b03c4b8c5fbde36021dc4_1440w.jpg

其他

v2-b78f933a842eac713777d89fc4006e79_1440w.jpg

总结

  • 在本文中介绍了go语言集成开发环境goland的安装、配置、激活、以及基本的快捷键用法

  • 在下文中,我们将介绍编辑器之神emacs中如何集成开发go代码

参考资料


Guess you like

Origin blog.51cto.com/13784902/2474126