Set up the Google Go language development tool Sublime Text 2 Environment on Mac OS X

Source: Internet
Author: User

Set up the Google Go language development tool Sublime Text 2 Environment on Mac OS X

The Go language is Google's own compiled language, designed to reduce Code complexity without compromising performance. Its advantage is to allow the software to give full play to the advantages of synchronizing multiple workers with multiple core processors, and to solve the trouble of object-oriented programming.

1. Install Golang SDK

In the official website http://golang.org/directly download the installation package to install. Download the latest installation package in pkg format and double-click it to run it. Follow the prompts to complete the installation.

After the installation is complete, open the terminal and enter go to check whether the Golang SDK is successfully installed. The following shows that the installation is successful:

You can also enter go version to view your installed Golang version.

II. Environment variable configuration (GOPATH)

GOPATH is used to tell Golang commands and other related tools where to find the Go package directory on your system.

GOPATH is a PATH list, similar to the PATH settings:

GOPATH =/home/USER/go:/home/USER/workspace_go :***

The path of each list item is actually a workspace. Each workspace should contain three directories: source file (src), related package (pkg), and execution file (bin.

Http://golang.org/doc/code.html

After creating a workspace, you can configure GOPATH (the configuration file is ~ /. Bash_profile ).

Export GOPATH =/Users/heinoc/go:/Users/heinoc/Documents/workspace/workspace_go

After saving, source ~ /. Bash_profile: The GOPATH configuration is completed. You can check the effect of the configuration in go env on the terminal.

(Note: I usually assign at least two directories to GOPATH. When you need to download the open-source package (go get ***), the first directory will be found by default in the open-source package, the project will be stored in the pkg folder in the first directory. All projects developed by my local machine are saved in the GOPATH directory at the end, just to facilitate the management of packages and how to configure them, depending on your personal preferences)

Iii. Development Tool configuration (Sublime Text 2)

Sublime Text 2: http://www.sublimetext.com/2

After the download is complete, install it directly.

Sublime Text 2 can be used free of charge, but after the number of storage times reaches a certain number, you will be prompted whether to purchase, click Cancel to continue to use, there is no difference with the official registration version.

Ubuntu installation code editor Sublime Text 3 (Build 3083)

Animation display 16 Sublime Text Shortcut Key Usage

Ubuntu 12.10 install and crack Sublime Text 2

Install Sublime Text 2 on Ubuntu 13.04

Code artifact-Sublime Text package management tools and extensions

How to Develop the Sublime Text 2 plug-in

Install and crack the Sublime Text 2 editor in Windows Mac Linux

Text Editor Sublime Text User Experience

1. install Package Control

Ctrl + 'Open the command line and execute the following code:

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'

Before installation:

After restarting Sublime Text 2:

This indicates that Package Control is successfully installed.

2. Install the GoSublime Plugin:

Command + Shift + P open the Package Control and enter the pcip address, as shown in:

Enter GoSublime in the subsequent interface and press enter to install GoSbulime. (The source code of this plug-in is in the https://github.com/DisposaBoy/GoSublime)

After the installation is complete, you can see the following in the menu:

Here, the Golang development environment of Sublime Text 2 is complete.

4. Start Golang

In your GOPATH workspace, create a folder under the src directory, name the project, and drag the folder to Sublime Text 2, you can open the project in Sublime Text 2, create a file in it, and save it as "***. go, and then you can start encoding:

Sublime Text 2 has the automatic complementing function for Golang code:

For compiled files, use the shortcut key Command + B to open the terminal of Sublime Text 2 and enter go build (name) to compile it:

After a prompt is displayed, run the shell command and execute the file./gotest that has just been compiled to view the program running result:

The running result is as follows:

Sublime Text details: click here
Sublime Text: click here

This article permanently updates the link address:

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.