Detailed configuration Sublime text 2/3 for the Golang development environment

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

1. Download and install sublime text 2/3

Official website Download: http://www.sublimetext.com/


2. After successfully installing sublime text, start sublime text, select "View", "Show Console" in the menu bar, or press the shortcut key "Ctrl +" to eject the console and enter the following content according to different versions to install " Package Contral "

1). Sublime Text 2

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 (' Restart Sublime Text to finish installation ')

2). Sublime Text 3

Import Urllib.request,os; PF = ' package control.sublime-package '; IPP = Sublime.installed_packages_path (); Urllib.request.install_opener (Urllib.request.build_opener (Urllib.request.ProxyHandler ())); Open (Os.path.join (IPP, PF), ' WB '). Write (Urllib.request.urlopen (' http://sublime.wbond.net/' + pf.replace (', '%20 ')) . Read ())

If the failure can access the official website address: HTTPS://SUBLIME.WBOND.NET/INSTALLATION#ST3


3. After the installation is successful, restart sublime text, under the "Preferences" item in the menu bar, you will see an item named "Package Control" and "Settings", click on it and enter "Install" in the pop-up box. Package ", press ENTER, enter" Gosublime "in the pop-up box and select" Gosublime "and press ENTER to install. After the installation is successful, restart sublime text, after the restart in the menu bar "Preferences" item in the "Package Settings" item will have a "gosublime" item, indicating that the installation was successful


4. Download and install go and git

Go's official website address: Http://tip.golang.so/doc/install

Git's website address: http://git-scm.com/downloads/


5. Under Windows to make sure that the go executable is in the environment variable path, you can perform go on the command line to test it, if it works correctly, and also make sure that the variable names named Goroot and Gopath are in the environment variables. Where Goroot is the Go installation folder (the default installation is: C:\Go\), and Gopath is the project folder for Test go compilation, which you can specify. The successful settings are as follows:



6. Execute the following command in the command line, should not error

Go get github.com/nsf/gocodego Install Github.com/nsf/gocode
After success, the%gopath% directory will be more than two directories, respectively, named Bin, Src. Where the bin directory has a name Gocode.exe file, and the SRC directory next to a directory named github.com.


7. Testing

Open Sublime text, click Project, Add folder to Project ... on the menu bar, and select the directory where the%gopath% is located

Create a new directory named Test under the%GOPATH%/SRC directory, and create a new file named Test.go under Directory, with the following contents:

Package Mainimport "FMT" Func Main () {FMT. Println ("Hello World")}

After saving, press the shortcut key ctrl+b after entering "go run Test.go", will output a "Hello world" to indicate the environment to build successfully, as follows:


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.