Basic knowledge-configure the golang development environment of sublime Text 3 in Ubuntu 14.04

Source: Internet
Author: User
1. Download and decompress golang (here we will extract it to the $ home/golang/directory as an example): http://www.golangtc.com/download2.pdf create a gopath-related directory (Here we use the $ home/golang/projects/directory as an example ~ /Golangmkdir ~ /Golang/projectsmkdir ~ /Golang/projects/3 rdpartymkdir ~ /Golang/projects/3 rdparty/binmkdir ~ /Golang/projects/3 rdparty/pkgmkdir ~ /Golang/projects/3 rdparty/srcmkdir ~ /Golang/projects/ownmkdir ~ /Golang/projects/own/binmkdir ~ /Golang/projects/own/pkgmkdir ~ /Golang/projects/own/src3, in $ home /. add the following content to bashrc and save (do not restart) Export goroot = $ home/golang/goexport gopath = $ home/golang/projects/3 rdparty: $ home/golang/projects/ownexport goarch = amd64export GOOS = linuxexport Gobin = $ goroot/binexport Path = $ path: $ goroot/bin4. Install gocode by running the following command on the terminal: go get-u github.com/nsf/gocodego install github.com/nsf/gocode5、download and install sublime Text 3, http://www.sublimetext.com/3 click the desired system access link to download Installation Package. 6. install package Control for sublime Text 3: Open sublime Text 3, press Ctrl + '(on the tab key), enter the following content, and press Enter: 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 () after installation, restart sublime Text 3. 7. Install gosublime and sidebarenhancements: Open sublime Text 3, press Ctrl + Shift + P, and enter PCIP in the pop-up window and press Enter, in this case, sublime Text 3 searches for the package information that can be installed through the network. Wait a moment and the package list will pop up. Enter gosublime and press enter to wait until the gosublime installation is complete. After the installation is complete, you may be prompted that the goroot gopath is not set, regardless of whether it is set or not (this is irrelevant to the gopath goroot set in the system environment variable ). Press Ctrl + Shift + P again. In the pop-up window, enter PCIP and press Enter. Wait a moment. The package list will pop up. Enter sidebarenhancements and press Enter. Wait until sidebarenhancements is installed. 8. Set gopath and goroot: Open sublime Text 3, choose preferences> package Settings> gosublime> Settings-default, and open the gosublime configuration file, modify the Env settings :{... // omit "env": {"goroot ":"~ /Golang/go "," gopath ":"~ /Golang/projects/3 rdparty :~ /Golang/projects/own "},... // omitted} after the settings are complete, restart sublime Text 3. 9. All settings are complete: Open sublime Text 3, write a golang code, and save it as test. Go.
--------------------------------------------------package mainimport (    "fmt")func main() {    fmt.Println("Hello World !")}--------------------------------------------------
Press Ctrl + B to open the compilation window and enter go run./test. Go to run the current file.
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.