1. Download and install sublime text 2/3
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 bring up the console, enter the following content based on 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( 'Please 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 visit the official site address: https://sublime.wbond.net/installation#st3
3. after the installation is successful, restart sublime text. Under "Preferences" in the menu bar, you will see an item named "package control" and "package Settings". Click it, enter "install package" in the pop-up box, press enter, enter "gosublime" in the pop-up box, select "gosublime", and press enter to install the package. After successful installation, restart sublime text. After restart, an item named "gosublime" is displayed in "package Settings" under "Preferences" on the menu bar, indicating that the installation is successful.
4. Download and install go and git
Go official site: http://tip.golang.so/doc/install
Git official site address: http://git-scm.com/downloads/
5. in Windows, make sure that the executable file of Go is in the path environment variable. You can run go in the command line for testing. If the file runs properly, it is correct; in addition, make sure that the environment variables include the goroot and gopath variable names. Goroot is the go installation folder (C: \ go \ is installed by default), and gopath is the project folder compiled by test go, which can be specified at will. The settings are as follows:
6. Execute the following commands in the command line in sequence. No error is reported.
go get github.com/nsf/gocode
go install github.com/nsf/gocode
After successful execution, the % gopath % directory contains two more directories named bin and SRC. In the binary directory, there is a file named gocode.exe, while in the src directory, there is another directory named github.com.
7. Test
Open sublime text, click "project"-> "add folder to project..." on the menu bar, and select the directory where % gopath % is located.
Create a directory named test under the % gopath %/src directory, and create a file named test. Go in the directory. The content of the file is as follows:
package main
import "fmt"
func main() {
fmt.Println("Hello World")
}
After saving, press Ctrl + B and enter "Go run test. Go". A "Hello world" is output, indicating that the environment is successfully set up, as shown below:
Detailed configuration of the golang development environment of sublime text 2/3