[Go] Use of Go language development tool GoLand (22)

Past review:

foreword

insert image description here

Goland is a cross-platform commercial IDE developed for Go by Czech software development company JetBrains. Goland has Strong Code Insight, Navigation & Search, Run & Debug, Integration with VCSs, More than just a Go IDE and strong Extensibility, which can help Gopher read and write Go code easily and quickly.

The IDE produced by JetBrains has a good reputation in the industry, such as Clion for C/C++, IntellijI IDEA for Java, PyCharm for Python, PhpStorm for PHP, WebStorm for JavaScript, etc. Once launched, Goland has been loved by many Gophers. It is recommended that you use it as the preferred IDE for Go.

The only regret is that Goland is a paid product. If you don't have the conditions or are bothered to crack it, the open source and free VSCode is also a good choice.

GoLand is a Go language IDE from the Jetbrains family, with a 30-day free trial period.

The installation is also very simple. Visit the download page of Goland, and download the corresponding software according to your current system environment on the three major platforms (Mac, Linux, Windows).

Get started quickly

The first step is to create a project.

File > New > Project

insert image description here

The second step is to configure GOROOT, which is the installation directory of Go. Here you need to install Go in advance.

File > Settings > Go > GOROOT

insert image description here

The third step is to configure GOPATH, which is the location where the Go source code, dependent packages and compiled executable files are stored. Multiple GOPATHs can be set.

File > Settings > Go > GOPATH

insert image description here

The src directory under GOPATH is the main directory of the next development program. All source code should be placed under this directory. Generally, our approach is to use one directory for one project.

The fourth step is to create the helloworld program. The Go project directory I created is as follows:

insert image description here

The fifth step is to compile and run helloworld.

右键 helloworld > Run > go build helloworld

The output is as follows:

insert image description here

common settings

  • change theme
File > Settings > Editor > Color Scheme
  • Change font type, size and line spacing
File > Settings > Editor > Font
  • Change code file encoding method
File > Settings > Editor > File Encodings
  • Modify Tab to specify the number of spaces, the default is 4 spaces
File > Settings > Editor > Code Style > Go

Commonly used shortcut keys

file related

CTRL + E: Open recently viewed files
CTRL + SHIFT + E: Open recently modified files
CTRL + SHIFT + N: Find files

find and locate

CTRL + R: replace text
CTRL + F: find text
CTRL + SHIFT + F: perform a global search
CTRL + G: quickly locate a line
CTRL + B: jump to the definition and reference of a method or structure
CTRL + left click: equivalent to CTRL + B
CTRL + ALT + Left/Right: go back or forward to the last cursor position

code editing

CTRL + ALT + T: Wrap the code in a code block, such as if{...} else{...}
CTRL + /: single-line comment
CTRL + SHIFT + /: multi-line comment
CTRL + +: collapse code block, structure or function CTRL + -: expand code block, structure or function
SHIFT
+ ENTER: insert a new line down
CTRL + Backspace: delete by word CTRL + D: copy the line where the current cursor is CTRL + X: cut ALT + SHIFT + UP/DOWN on the line where the cursor is
currently located : you can move the code in the line where the
cursor is located up and down CTRL + SHIFT + U: you can convert the selected content to upper and lower case

references

  • [1] JetBrains official website
  • [2] JetBrains Goland official website
  • [3] GO language from entry to abandonment II: Goland installation and configuration

Guess you like

Origin blog.csdn.net/u011397981/article/details/131865570