This is a creation in Article, where the information may have evolved or changed.
Auth:philo version:1.2
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)
1. Installing Mercurial:brew install mercurial> This thing is used for versioning, and is also a tool to download code similar to git, it seems that Google's projects are very much.
2. Install Golint:
$ go get github.com/golang/lint $ go install github.com/golang/lint
Installing Gooracle
go get code.google.com/p/go.tools/cmd/oracle
Installing Goimport
go get golang.org/x/tools/cmd/goimports
Installing Gocode
go get -u github.com/nsf/gocode
Installing Godef
go get -v code.google.com/p/rog-go/exp/cmd/godefgo 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. > Solutions:
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
Various tool files will $GOPATH/bin/
appear in the After Go install
- Gocode provides code completion
- Godef Code Jump
- GOFMT Automatic Code collation
- Golint code Syntax checking
- Goimports Auto-Organize imports
- Oracle Code callgraph query (plugin is still in todolist, but the error is not configured.) Really annoying. )
> Finally don't forget to copy the above command to $GOROOT/bin/ below
Final configuration results (Package->go plus->display Go information after installation)
Cover Tool: /usr/local/go/pkg/tool/darwin_amd64/coverVet Tool: /usr/local/go/pkg/tool/darwin_amd64/vetFormat Tool: /Users/Li-jianying/git/bin/goimportsLint Tool: /usr/local/go/bin/golintGocode Tool: /Users/Li-jianying/git/bin/gocodeGocode Status: EnabledOracle Tool: /Users/Li-jianying/git/bin/oracleGit: /usr/bin/gitMercurial: /usr/local/Cellar/mercurial/3.2.1/bin/hgPATH: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin
There is no problem without a red line.
Project management, automatic file jump
Plug-in:project-manager> This plugin is very hot, on the home page of Atom.io is still very front.
Usage Details:
( cmd - \)
Close Project file with tree view open
Search for Project ( cmd -t )
files > enter keywords in order of entry
For example, the go source code in the user module's controll
Multiple shortcut keys can be used when searching = "User controll Go"
We 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.
Summarize:
The fact that the TreeView uses this plugin is not very large, because there are a lot of project files for normal projects.
It's easy to open items (folders) quickly, and it's pretty cool to work with quick open files.
Press the shortcut key after the effect shows:
Automatic grammar checking, auto-completion
Plugin Go-plus,autocomplete-plus (dependance), Gocode
Install with APM installation. Speed is also possible.
Use details at the time of saving
- will automatically fill in imports
will automatically organize the code > For example A:=5 will become a: = 5
Two blank lines automatically become a space
Lint automatically check for syntax errors (go build errors will be displayed)
- Vet will automatically check grammar spelling suggestions > functions, and structure experience prompts for comments.
> For example, you will be prompted to add a Godoc type comment before the function://functionname
The first line of the > Note requires a double-slash comment + space + function name + Space + Short 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 it is in disrepair. The API has an older version, so API warnings always appear. (I'm a pragmatic, blind eye)
- Gocode if it is not found, enter the code to find the file Autocomplete-view.coffee 105 lines in the absolute path is certainly no problem.
Bind shortcut keys, because this plugin does not bind the shortcut key files (keymap) so need to Keymap.cson under the manual binding configuration as follows:
'.active.pane':'ctrl-;': 'gocode:toggle'
Effect Demo
## 查找定义
- 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
- Installing the plugin Atom-runner
- Modify the go run in the source code as
go: 'sh [绝对路径到你的全局run脚上] '+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)
>
'.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.
Transfer from 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/