Golang Environment Configuration Recommendations

Source: Internet
Author: User
Tags mercurial gocode

Essential features of the development environment
    1. Project Management

    2. Quick file Jump

    3. Automatic grammar checking

    4. Auto-complete

    5. Find definition

    6. Fast Start-up speed

    7. If you have a need, plug-ins can be written casually

    8. Flexible Run configurations

Big environment
    1. Os x

    2. GO 1.4

    3. 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.

    1. Environment configuration: (golint,gooracle,mercurial)

      1. Installing Mercurial:brew Install Mercurial

        This thing is used for versioning, but also a tool to download the 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
    1. Installing Gooracle


Go get code.google.com/p/go.tools/cmd/oracle
    1. Installing Goimport


Go get golang.org/x/tools/cmd/goimports
    1. Installing Gocode


Go get-u github.com/nsf/gocode
    1. 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
    1. When installing the environment, there will always be a download 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. The
      is ok when put into the gopath.
      This step can only be used to override the go get step, and finally go to install

    2. The various tool files appear in   $GOPATH/bin/ after go install

      Finally don't forget to copy the above command Under $GOROOT/bin/

      1. Gocode provide code completion

      2. Godef code Jump

      3. Gofmt Automatic code collation

      4. Golint code Syntax check

      5. Goimports Auto-organize imports

      6. P>oracle Code callgraph query (plugin is still in ToDoList, but not configured always error. Really annoying.

    3. Final configuration results (after installation package->go plus->display Go information)


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
  1. Plugin: Project-manager

    This plugin is very hot, in the Atom.io of the first page ranking or very forward.

  2. Usage Details:

      1. ( cmd - \)Close Project file with tree view open

      2. Search for project files( cmd -t )

        Enter the keywords in the order they are entered
        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.

      3. Open Project List( ctrl-cmd-p )

        Then it will show a list of items. Enter to open the project.

  3. 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.

  4. Press the shortcut key after the effect shows:


    Automatic grammar checking, auto-completion
  5. Plugin Go-plus,autocomplete-plus (dependance), Gocode
    Install with APM installation. Speed is also possible.

  6. Use details at the time of saving

      1. will automatically fill in imports

      2. will automatically organize the code

        For example, A:=5 will become a: = 5
        Two blank lines automatically become a space

      3. Lint automatically check for syntax errors (go build errors will be displayed)

      4. Vet will automatically check grammar spelling suggestions

        The function, the structure realizes the hint to fill the comment.
        For example, you will be prompted to add a Godoc type comment before the function://functionname
        The first line of the comment needs to use a double slash comment + space + function name + space + Short function function description.

  7. Usage Details: at the time of editing

      1. Go-plus will cooperate with Autocomplete-plus will automatically fill the whole Package name (tab completion, enter No, this is really comfortable)

      2. The package name. Then the first few letters of the input method name give the completion advice.

  8. Post-installation demo (similar to go-plus official demo)

  9. Gocode Plugin Auto Complement demo

      1. 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)

      2. 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.

      3. 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 '
    1. Effect Demo


      Find definition
    2. Plugin Godef

    3. 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
    1. Installing the plugin Atom-runner

    2. Modify the go run in the source code asgo: ‘sh [绝对路径到你的全局run脚上] ‘+atom.project.getRepo().project.path

    3. 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.

    4. When you're done, you can run the entire project regardless of what files are currently being viewed.

    5. Other languages can do the same. After all, a single file project is not very common (at the time of development)

Summarize
    1. I'm just summarizing all the Golang-related atom plugins I've used.

    2. Believe that Golang use the editor is enough. Because go tool it is very useful.

My key map
    1. cmd-dDuplicate line

    2. cmd-wClose Label

    3. cmd-rList of tags within a file

    4. cmd-eUse the selected content to do the pattern of the search

    5. shift-cmd-fProject internal search, this is very practical. Command Configuration (Keymap.cson)
      >


'. Platform-darwin atom-text-editor ': ' shift-cmd-d ': ' Find-and-replace:select-next '


Golang Environment Configuration Recommendations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.