This is a creation in Article, where the information may have evolved or changed.
1.4 Go development tools
In this section I'll cover several development tools that have automated tips to automate FMT functionality. Because they are all cross-platform, the installation steps and the like are common.
Liteide
Liteide is a cross-platform lightweight integrated development environment (IDE) developed specifically for the Go language, written by VISUALFC.
Figure 1.4 Liteide Main interface
Liteide Main Features:
- support major operating systems
- Windows
- Linux
- MacOS x< /li>
- Go compilation environment management and switchover
- manage and switch multiple go compilation environments
- support Go Language cross-compilation
- project management with GO standards
- Gopath-based package browser
- Gopath-based compilation system
- Gopath-based API document retrieval
- Go language editing support
- class Browser and outlining
- Gocode (Code autocomplete tool) Perfect support
- go language document viewing and API Quick Search
- code expression information display
F1
- source code definition Jump support
F2
- gdb breakpoints and debugging support
- GOFMT Automatic formatting support
- Other features
li> support multi-language interface display
- full plug-in architecture
- support Editor color scheme
- based on Kate's syntax display support
- full text-based word autocomplete
- support key Disk Accelerator binding scheme
- markdown Document editing support
- Live preview and synchronous display
- custom CSS display
- export HTML and PDF documents
- Bulk Convert/merge to Html/pdf document
Liteide installation Configuration
Liteide Installation
- Download Address Http://code.google.com/p/golangide
- Source Address Https://github.com/visualfc/liteide
First install the Go language environment, and then according to the operating system download liteide corresponding compressed files directly decompression can be used.
Installing Gocode
Enabling the Go language Input AutoComplete requires the installation of Gocode:
go get -u github.com/nsf/gocode
Compiling environment settings
Switch and configure the environment variables currently used by liteide according to its own system requirements.
Take the Windows operating system, 64-bit go language as an example, the toolbar's environment configuration select Win64, point 编辑环境
, enter liteide edit win64.env file
GOROOT=c:\goGOBIN=GOARCH=amd64GOOS=windowsCGO_ENABLED=1PATH=%GOBIN%;%GOROOT%\bin;%PATH%。。。
GOROOT=c:\go
change it to the current go installation path, save it, if you have MinGW64, you can c:\MinGW64\bin
join path so that go calls GCC support CGO compilation.
Take the Linux operating system, 64-bit go language as an example, the toolbar's environment configuration select linux64, point 编辑环境
, enter liteide edit linux64.env file
GOROOT=$HOME/goGOBIN=GOARCH=amd64GOOS=linuxCGO_ENABLED=1PATH=$GOBIN:$GOROOT/bin:$PATH 。。。
GOROOT=$HOME/go
change it to the current go installation path and save it.
Gopath settings
The Go language toolchain uses Gopath settings, a list of project paths developed by the go language, and a Ctrl+,
quick view of Gopath documents on the command line (which can also be entered directly in Liteide) go help gopath
.
The Gopath can be easily viewed and set in Liteide. By 菜单-查看-GOPATH
setting, you can view the list of Gopath that already exist on your system and add the project directory to your custom Gopath list as needed.
Sublime Text
Here will introduce sublime Text 2 (hereinafter referred to as sublime) +gosublime+gocode+margo combination, then why choose this combination?
The automation hint code, as shown in
Figure 1.5 Sublime Automation prompt interface
When you save it, the code is automatically formatted to make the code you write more beautiful and compliant with GO standards.
Support Project Management
Figure 1.6 Sublime Project management interface
Support Syntax highlighting
Sublime Text 2 is free to use, just after a certain number of Save times will prompt whether to buy, click Cancel continue to use, and the official registration version no difference.
Let's talk about how to install, download sublime
According to their respective system to download the appropriate version, and then open Sublime, for unfamiliar sublime students can first look at this article sublime Text 2 Getting Started and tips
After you open the package control:ctrl+ Open the command line, execute the following code:
import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print 'Please restart Sublime Text to finish installation'
This time restart sublime, you can find in the menu bar more than one of the following columns, that the package control has been installed successfully.
图1.7 sublime包管理
Next, install Gocode and Margo. Open the terminal and run the following code (git required)
go get github.com/nsf/gocodego get github.com/DisposaBoy/MarGo
At this point we will find that there are $GOPATH/bin
two more executables, Gocode and Margo, which will start automatically when the Gosublime is loaded.
- After installation, you can install the sublime plugin. To install Gosublime, sidebarenhancements, and go Build, after installing the plugin remember to restart sublime to take effect, ctrl+shift+p open the package controll input
pcip
Control:install package "abbreviation).
At this time, the lower left corner shows that the packet data is being read and the following interface appears after completion
图1.8 sublime安装插件界面
This time enter gosublime, press OK to start the installation. The same applies to sidebarenhancements and go Build.
- To verify that the installation is successful, you can open the sublime, open the Main.go, see if the syntax is highlighted, the input is
import
not an automated hint, and import "fmt"
then the input fmt.
is not a function of the automation prompt.
If this prompt is already present, you have completed the installation and have completed the automatic prompt.
If you do not have such a hint, you are generally $PATH
not configured correctly. You can open the terminal, enter the Gocode, is not able to run correctly, if not, it is $PATH
not configured correctly.
Vim
Vim is the development of a text editor from VI, code completion, compilation and error jumps and other convenient programming features are particularly rich, in the programmer is widely used.
Figure 1.9 Vim Editor Automation tips Go interface
Configure VIM highlighting
cp -r $GOROOT/misc/vim/* ~/.vim/
Adding syntax highlighting in the ~/.VIMRC file
filetype plugin indent onsyntax on
Installing Gocode
go get -u github.com/nsf/gocode
Gocode is installed to the following by default $GOBIN
.
Configure Gocode
~ cd $GOPATH/src/github.com/nsf/gocode/vim~ ./update.bash~ gocode set propose-builtins truepropose-builtins true~ gocode set lib-path "/home/border/gocode/pkg/linux_amd64"lib-path "/home/border/gocode/pkg/linux_amd64"~ gocode setpropose-builtins truelib-path "/home/border/gocode/pkg/linux_amd64"
The meaning of the two parameters inside the Gocode set is explained:
Propose-builtins: Whether to automatically prompt for Go's built-in functions, types and constants, default to False, not prompt.
Lib-path: By default, Gocode only searches for packages $GOPATH/pkg/$GOOS _$goarch and $GOROOT/pkg/$GOOS _$goarch directory. This setting, of course, allows us to set the path that our extra lib can access.
Congratulations, the installation is complete, you can now use to :e main.go
experience the fun of developing go.
Emacs
The legendary artifact of Emacs, she is not just an editor, it is an integrated environment, or it can be called an integration development environment, these features such as the user in the full-featured operating system.
Figure 1.10 Emacs Edit Go Main interface
Configuring Emacs Highlighting
cp $GOROOT/misc/emacs/* ~/.emacs.d/
Installing Gocode
go get -u github.com/nsf/gocode
Gocode is installed to the bottom of the box by default $GOBIN
.
Configure Gocode
~ cd $GOPATH/src/github.com/nsf/gocode/emacs~ cp go-autocomplete.el ~/.emacs.d/~ gocode set propose-builtins truepropose-builtins true~ gocode set lib-path "/home/border/gocode/pkg/linux_amd64" // 换为你自己的路径lib-path "/home/border/gocode/pkg/linux_amd64"~ gocode setpropose-builtins truelib-path "/home/border/gocode/pkg/linux_amd64"
Need to install Auto completion
Download AutoComplete and Unzip
~ make install DIR=$HOME/.emacs.d/auto-complete
Configuring the ~/.emacs File
;;auto-complete (require 'auto-complete-config) (add-to-list 'ac-dictionary-directories "~/.emacs.d/auto-complete/ac-dict") (ac-config-default) (local-set-key (kbd "M-/") 'semantic-complete-analyze-inline) (local-set-key "." 'semantic-complete-self-insert) (local-set-key ">" 'semantic-complete-self-insert)
More Information reference: Http://www.emacswiki.org/emacs/AutoComplete
Configure. Emacs
;; Golang mode (Require ' go-mode-load) (Require ' go-autocomplete);; Speedbar;; (Speedbar 1) (speedbar-add-supported-extension ". Go") (Add-hook ' Go-mode-hook ' (lambda ();; Gocode (Auto-complete-mode 1) (setq ac-sources ' (ac-source-go));; Imenu & Speedbar (setq imenu-generic-expression ' ("type" "^type *\\ ([^ \t\n\r\f]*\\)" 1) ("Func" "^f UNC *\\ (. *\\) {"1)") (Imenu-add-to-menubar "Index");; Outline mode (make-local-variable ' Outline-regexp) (setq outline-regexp "//\\.\\|//[^\r\n\f][^\r\n\f]\\|pack\\|func\ \|impo\\|cons\\|var.\\|type\\|\t\t* ... ") (Outline-minor-mode 1) (local-set-key" \m-a "' Outline-previous-visible-he ading) (local-set-key "\m-e" ' outline-next-visible-heading);; Menu bar (Require ' Easymenu) (Defconst go-hooked-menu ' ("Go Tools" ["Go run buffer" Go t] ["Go Reformat buffer "Go-fmt-buffer t" ["Go check buffer" Go-fix-buffer T])) (Easy-menu-define Go-added-menu (current-LOCAL-MAP) "Go tools" go-hooked-menu);; Other (setq show-trailing-whitespace t)); Helper function (Defun go () "Run Current buffer" (interactive) (Compile (concat "Go Run" (buffer-file-name))); Helper function (Defun go-fmt-buffer () "Run gofmt on current buffer" (interactive) (if Buffer-read-only (Prog N (Ding) (message "Buffer is read Only")) (Let (P (line-number-at-pos)) (filename (buffer-file-name)) (Old-max-mini-window-height max-mini-window-height)) (Show-all) (if (get-buffer "*go reformat errors*") (Progn (delete-windows-on "*go reformat errors*") (kill-buffer "* Go reformat errors* ")) (setq max-mini-window-height 1) (If (= 0 (Shell-command-on-region (point-min) (Point -max) "Gofmt" "*go reformat output*" nil "*go reformat errors*" T)) (Progn (Erase-buffer) (insert-buffer- Substring "*go reformat output*") (Goto-char (Point-min)) (FORWArd-line (1-p))) (With-current-buffer "*go reformat errors*" (Progn (Goto-char (Point-min)) (while (R E-search-forward "<standard input>" nil t) (Replace-match filename)) (Goto-char (Point-min)) (c Ompilation-mode))) (Setq max-mini-window-height old-max-mini-window-height) (delete-windows-on "*Go Reforma T output* ") (kill-buffer" *go reformat output* "))); Helper function (Defun go-fix-buffer () "Run Gofix on current buffer" (interactive) (Show-all) (Shell-command-o N-region (point-min) (Point-max) "Go Tool Fix-diff")
Congratulations, you can now experience the fun of developing go in the artifact. The default speedbar is off if it is needed to turn it on;; (Speedbar 1) The previous comment is removed, or it can be opened manually via the m-x Speedbar .
Eclipse
Eclipse is also a very common development tool, and the following describes how to use Eclipse to write go programs.
Figure 1.11 Eclipse edit Go Main interface
First download and install Eclipse.
Download Goeclipse Plugin
Http://code.google.com/p/goclipse/wiki/InstallationInstructions
Download Gocode, code completion tips for Go
Gocode's GitHub Address:
https://github.com/nsf/gocode
To install git under windows, you typically use Msysgit
Install again under cmd:
go get -u github.com/nsf/gocode
You can also download the code and compile it directly with go build, which will generate Gocode.exe
Download the MinGW and install it as required.
Configure Plug-ins
Windows->reference->go
(1). Configure the Go Compiler
Figure 1.12 Setting some basic information for go
(2). Configure Gocode (optional, code completion), set the Gocode path to the previously generated Gocode.exe file
Figure 1.13 Setting Gocode information
(3). Configure GDB (optional, do a tune trial), set the GDB path to the Gdb.exe file in the MinGW installation directory
Figure 1.14 Setting GDB information
Whether the test was successful
Create a new Go project and build a hello.go. Such as:
Figure 1.15 Creating a new project Edit file
Debug as follows (to debug with input commands in the console):
Figure 1.16 Debug Go Program
IntelliJ idea
Readers familiar with Java should be unfamiliar with idea, which is supported by a plugin to support the highlight syntax of the go language, code hints and refactoring implementations.
First download Idea,idea support multi-platform: win,mac,linux, if the money to buy a formal version, if not the use of Community free version, for just the development of the Go language free version is sufficient
Install the Go plugin, click Setting in the menu file, find plugins, click, broswer Repo button. Domestic users may error, solve their own ha.
This time will see a lot of plug-ins, search find Golang, double-click, download and install. Wait until the Golang line appears behind the downloaded flag, click OK.
Then click Apply. The IDE will ask you to reboot.
When the restart is complete, creating a new project will find that you can already create the Golang project:
Next, you will be asked to enter the location of the Go SDK, usually installed in C:\go,linux and Mac according to their own installation directory settings, check the directory OK.
Transferred from: http://studygolang.com/articles/1678