Specific description of the structure sublime text 2/3 of 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 the installation is successful sublime text. Start sublime text. Select the menu bar "View", "Show Console" or press the shortcut key "Ctrl +" directly. Pop-up console. Enter the following to install the "package Contral" according to the different version numbers

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 you fail, you can visit the official website address: HTTPS://SUBLIME.WBOND.NET/INSTALLATION#ST3


3. After successful installation, restart sublime text, under the "Preferences" item in the menu bar, you will see an item named "Package Control" and "Package Settings", click it, 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 successful installation, restart sublime text. After restarting, there is an item named "Gosublime" in the "package Settings" item under the "Preferences" item in the menu bar, indicating a successful installation


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, make sure that the executable file for Go is in the environment variable path. You can run go on the command line to test it, assuming it is correct to run correctly. Also make sure that the variable names in the environment variables are named Goroot and Gopath. Goroot is the Go install directory (default installation is: C:\Go\), and Gopath is the test go compiled project directory, can be arbitrarily specified.

After successful settings such as the following:



6. Run the command line in sequence such as the following commands, should not error

Go get github.com/nsf/gocodego Install Github.com/nsf/gocode
After successful, the%gopath% folder will be more than two folders, respectively named Bin, Src. In the Bin folder there is a file named Gocode.exe, and the Src folder next to a folder named Github.com.


7. Test

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

Create a new folder named Test under the%gopath%/src folder, and create a new file named Test.go under the folder. Its contents such as the following:

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 builds successfully, for example the following:


Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.

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.