This is a creation in Article, where the information may have evolved or changed.
[TOC]
Flip through this article for the first time with atom suggestions 跳着
Http://www.jianshu.com/p/aa8f8a252ed9
Search for 插件管理 Some of them
Preparation for the entire development
First, you need a golang environment.
But still need a ladder to install some necessary tools
Installing Https://atom.io/ATOM
Description: Because I use OSX development, if it is Windows please improvise, the principle is the same
Configuring the underlying environment variables
It should be clear that the GO environment variable is important for go, which is related to the success of debug compilation.
This is my configuration script, please modify the part which needs to be changed
# golang pathexport GOROOT=/usr/local/goexport PATH=$PATH:$GOROOT:$GOROOT/binexport GOPATH=$HOME/go:$HOME/MyProjects/GoLangProjectsGO_BIN_HOME=$HOME/go/binexport GO_BIN_HOMEexport PATH=$PATH:$GO_BIN_HOME
Modify GOROOT , this is based on your system, here is the path of OSX system, other systems please find themselves, the installation process will be prompted
Modify $HOME , this is the user's root directory, and if it is windows, replace it with your user root directory
Modification GOPATH , it is recommended to do more than 2 paths with : separate (Windows with; separate), the first as go get the environment path, and later as your own development directory
Modified GO_BIN_HOME , this directory is the corresponding GOPATH first directory below the bin directory, of course, can also increase the configuration, the role of the road is to let go get or such a go install command after the installation, the executable tool can be compiled
Check your configuration after configuration is complete
go env
Paste_image.png
Installing the Atom base plug-in
- Atom-beautify One-Touch code beautification
Code formatting plug-in, supported languages to view the Help document, this plugin needs to configure shortcut keys, recommended use shortcut keyscmd-alt-l
Configure the code to
'atom-text-editor': 'alt-cmd-l': 'atom-beautify:beautify-editor'
Paste_image.png
- Tokamak-terminal Win OSX Universal Command line tool Fork to Terminal-plus
Shortcut key ' CTRL ' Switch command panel
Paste_image.png
This command line automatically finds your project root directory.
- Terminal-plus Win OSX Universal command-line tool, currently the best one (stop update cannot support ATOM 1.7) above
Install the above do not install this!
- File-icons Add nice icons to the file.
Paste_image.png
- Git-plus is basically consistent with the Sublimegit function of sublime Text
Shortcut key shift-cmd-p after input gitadd and so on, very convenient
Paste_image.png
Submit Save shortcut key cmd+s , do not save this commit ascmd+w
Install Atom plug-in for Golang
Go-config
Https://atom.io/packages/go-config
This is the fundamental to allow atom to use Golang, after installation in this plugin to Setting->GOPATH fill in
Above GOPATH , the absolute path is required here
Paste_image.png
Environment
Https://atom.io/packages/environment
This is a compatible environment, and it is possible that a high version atom does not need to be installed to use
Go-get
Https://atom.io/packages/go-get
Once you have installed the above 2 environments, you can use this plug-in on Atom go get
Shortcut key shift+cmd+p call out Command menu input go get can be called out, shortcut keys on the right
The Go plugin installed will be under your first Gopath
Go-import Quick Introduction Library
Https://atom.io/packages/go-imports
This plugin allows you to introduce the library, using the prerequisites is already installed Goimports, if not run this script
go get -v golang.org/x/tools/cmd/goimports
Plugin cannot be used after plug-in installation, need to configure the path of plug-in Settings->goimports path
Here you need to fill in the absolute path, for example, my is/Users/sinlov/go/bin/goimports
Paste_image.png
Use the shortcut key shift+cmd+p to call out the Command menu go import and enter to call out, shortcut keys on the right
Paste_image.png
This plugin will not be introduced when you have a grammatical error, and will be incorrect.
Autocomplete-go Auto-complete
Https://atom.io/packages/autocomplete-go
Use this plugin must be installed go-configenvironment
Run the script
go get -u github.com/nsf/gocode
or install it with the Go-get plugin just now.github.com/nsf/gocode
And then run
# 进入插件目录cd $HOME/go/src/github.com/nsf/gocode# 安装一次 gocodego install ./...# 设置自动补全开关为开启gocode set autobuild true# 再次安装go install ./...
Using Gocode
gocode -h
For use in Atom, first open the configuration
Paste_image.png
Click Default:.. andSuppress Activation For Characters
or enter in the Scope Blacklist
.source.go .comment, .source.go .constant.numeric, .source.go .string.quoted
In the Suppress Activation For Characters input
comma, newline, space, tab, /, \, (, ), ", ', :, ;, <, >, ~, !, @, #, $, %, ^, &, *, |, +, =, [, ], {, }, `, ~, ?, -
To take effect auto-complete
Paste_image.png
Gotests Test Code generator
Https://atom.io/packages/gotests
Plug-in run dependencies that automatically generate test code
go get -u github.com/cweill/gotests/...cd $HOME/go/src/github.com/cweill/gotestsgo install ./...
The use method is the code block right-clickGenerate Go tests
Paste_image.png
Right-click menu a bit more, ignoring other plugins
or use the command linegotests
# 查看帮助gotests -h# 查看测试代码gotests -all [testFile]# 生成测试代码gotests -all -w [testFile]
Paste_image.png