This is a creation in Article, where the information may have evolved or changed.
http://www.philo.top/2015/02/06/golang-%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE%E5%BB%BA%E8%AE%AE/
Essential features of the development environment
- Project Management
- Quick file Jump
- Automatic grammar checking
- Auto-complete
- Find definition
- Fast Start-up speed
- If you have a need, plug-ins can be written casually
- Flexible Run configurations
(Project,lint,hint,autocomplete)
To achieve the above points we will step-by-step configuration.
My big environment.
- Os x
- GO 1.4
- HomeBrew
Go Environment installation
This part is the most important, if without it, each build when the appearance of too many errors heart really is very sad.
Environment configuration: (golint,gooracle,mercurial)
- Installing Mercurial:brew Install mercurial > This thing is for version management, but also a tool to download code like Git, it seems that Google's projects with a lot of.
- Install Golint:
shell $ go get github.com/golang/lint $ go install github.com/golang/lint
- Installing Gooracle
shell go get code.google.com/p/go.tools/cmd/oracle
- Installing Goimport
shell go get golang.org/x/tools/cmd/goimports
- Installing Gocode
shell go get -u github.com/nsf/gocode
- Installing Godef
shell go get -v code.google.com/p/rog-go/exp/cmd/godef go install -v code.google.com/p/rog-go/exp/cmd/godef
Installation environment often appear to download the problem, probably my network is not good. There are often problems connecting to Google. > Solution: > Golang China's Download channel has a third-party package download tool, as long as the input address will be provided to you to download the tar package. > put it in the Gopath and it's OK. > This step can only replace the go get step, and finally need go install
g o after install will be in $GOPATH/bin/
Various tool files appear
- gocode provides code complement
- godef Code Jump
- gofmt Automatic code grooming
- golint code syntax check /li>
- goimports Auto-organize imports
- oracle Code callgraph query (plugin is still in ToDoList, but not configured always error. Really annoying. )
finally don't forget to copy the above command to $GOROOT/bin/ below
- final configuration results (after installation package->go Plus->display Go Information )
cover tool:/usr/local/go/pkg/tool/darwin_amd64/cover Vet tool:/usr/local/go/ Pkg/tool/darwin_amd64/vet Format Tool:/users/li-jianying/git/bin/goimports Lint tool:/usr/local/go/bin/golint Gocode tool:/users/li-jianying/git/bin/gocode gocode status:enabled Oracle tool:/users/li-jianying/git/bin/oracle Git:/usr/bin/git Mercurial:/usr/local/cellar/mercurial/3.2.1/bin/hg PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin :/sbin:/usr/local/go/bin
There's no problem with a red line.
Project management, automatic file jump
- Plug-in: Project-manager > This plugin is very hot, in the Atom.io home page ranking or very forward.
- Usage Details:
( cmd - \)
Close Project file with tree view open
- Search for Project
( cmd -t )
files > Input keywords in order to enter the keyword > such as the user module controll in the Go source code > Search can use multiple shortcut keys = "User controll go > can Find the source code exactly.
- Open the project
( ctrl-cmd-p )
list > then it will show a list of items. Enter to open the project.
Summary: > Feel this plugin's TreeView use is really not very large, because there are a lot of project files for normal projects. > is just quick to open the Project (folder) is very convenient, with the quick open file is still quite cool.
Press the shortcut key after the effect shows:
Automatic grammar checking, auto-completion
Plug-in Go-plus,autocomplete-plus (dependance), Gocode installation with APM install. Speed is also possible.
make With details
-
-
- lint automatically check for syntax errors (errors in Go build will be displayed)
Li style= "margin:0px; padding:0px ">vet will automatically check the grammar spelling suggestions > functions, the Structure experience prompts to fill in the comments. For example, you will be prompted to add a Godoc type of comment before the function://functionname The first line of the comment needs to use double slash comment + space + function name + space + Short function function description.
Usage Details: at the time of editing
- Go-plus will cooperate with Autocomplete-plus will automatically fill the whole Package name (tab completion, enter No, this is really comfortable)
- The package name. Then the first few letters of the input method name give the completion advice.
Post-installation demo (similar to go-plus official demo)
Gocode Plugin Auto Complement demo
- This plugin inherits from AutoComplete, Because of the neglect of the old. The API has an older version, so API warnings always appear. (I am pragmatic, blind)
- gocode if not found, enter the code to find the file Autocomplete-view.coffee The absolute path in 105 lines is definitely no problem.
- bind shortcut because the plugin does not have a file bound to the shortcut (KEYMAP) so you need to manually bind the configuration under Keymap.cson as follows:
json '. Active.pane ': ' Ctrl; ': ' Gocode:toggle '
effect demo
find definition
Plugin Godef
Usage Details: When the cursor is on the target code, use the shortcut key ctrl-k
to jump to the definition code of the target code.
Flexible operation
- install plug-in Atom-runner
- go: ' sh [absolute path to your global run pin] ' +atom.project.rootdirectories[0].path
- The script will be the path to your project's run. Then all of your projects can add a run.sh to specify a scenario for the build to run.
- When you're done, you can run the entire project regardless of what files are currently being viewed.
- Other languages can do the same. After all, a single file project is not very common (at the time of development)
Summarize
- I'm just summarizing all the Golang-related atom plugins I've used.
- Believe that Golang use the editor is enough. Because
go tool
it is very useful.
My key map
cmd-d
Duplicate line
cmd-w
Close Label
cmd-r
List of tags within a file
cmd-e
Use the selected content to do the pattern of the search
shift-cmd-f
Project internal search, this is very practical. Command configuration (Keymap.cson) >json '.platform-darwin atom-text-editor': 'shift-cmd-D': 'find-and-replace:select-next'
Thanks Golang
- Golang can have such a development experience and be so good in such a low version. Daniel has given us the best gift.
- The development experience of Golang with such good development tools plus a variety of extensibility editors (Vim,emacs,sublime,atom, etc.) is really good.