Golang Development Environment Building (under Windows)

Source: Internet
Author: User
Tags install go sublime text gocode
This is a creation in Article, where the information may have evolved or changed.

A preface

The main ways to build a go development environment are:

    1. Goeclipse
    2. Sublime text + gosublime + gocode
    3. Liteide

The first, the slower, the third, a software to be installed; The second method is recommended.

Two steps

  1. Install go environment, configure Goroot and Gopath, add path variable
  2. Install package controll ( crtrl + 反引号 enter command)

    Enter the following and press ENTER (different versions of Sublime, which seem to differ).

    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'    
  3. Install Gosublime pakcage ( ctrl + shift + p enter Package manager)

    Enter install a carriage return and enter a dialog box to install Pakcage
    Enter GoSublime return
  4. Install Gocode (Language auto-complete daemon) (using go get the GIT environment installed)

    1. go get -u github.com/nsf/gocodeGet project file
    2. go install github.com/nsf/gocodeCompile the project file to get the executable file
    3. Configure Gosublime to use it

      Preferences ==> Package Settings ==> gosublime ==> settings-default

      Add the file's

      "env":{},

      Switch

      "env":{     "path":"E:\\GoRepo\\gocode\\bin"     },

      Among them, the E:\\GoRepo author holds the total directory of the downloaded Go Library, E:\GoRepo\gocode\bin ' contains the Gocode executable file.

  5. Writing a Hello file
  6. ctrl + bSwitch to side bar display status

    [ E:/workspaces/golang/hello/ ] go build hello.go[ E:/workspaces/golang/hello/ ] hello

The first go project of the three

For example, E:\\workspaces\\golang create a new Web project in:

$ cd /e/workspaces/golang$ mkdir myweb$ cd myweb$ mkdir src$ mkdir bin$ cd src$ mkdir server      // 弄个server包$ // 在server包下创建server.go文件$ cd ../bin$ go build server   // 编译server.go文件(如果server.go引入了其它包的文件,则编译其它包)$ ./server            // 运行server

* * NOTE: * * In order to build this project, "E:\workspaces\golang\myweb" must be added to the GOPATH environment variable.

When developing under Sublime, you can Preferences ==> package settings ==> gosublime ==> Settings-user to add the following to the file:

{"env": {"GOPATH":"E:\\workspaces\\golang\\myweb"}}
Related Article

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.