This is a creation in Article, where the information may have evolved or changed.
The Go language Hello world! Code:
[Java]View Plaincopyprint?
- package main
-   
- import   
- Func Main () {
- fmt. Println (
- }
Next comes the installation of the go development environment for everyone.
The first is to install Go, here is a detailed installation instructions, Http://code.google.com/p/golang-china/wiki/Install or Http://golang.org/doc/install
Below we install under window, Google has to provide win installation package, for beginners or very simple!
Https://code.google.com/p/go/downloads/list
Direct next .... Installation is very simple!
After installing the go, we can build the development environment , here I use Sublime Text 2 + gosublime + Gocode. For those who do not know sublime Text 2, you can look at the official website: http://www.sublimetext.com/(generally a lightweight, handy tool)
1. Download Sublime Text 2, address as follows: http://www.sublimetext.com/
2. After the decompression, double-click Sublime_text, you can use sublime text 2.
3. Install the package Control, after opening Sublime Text 2, press the shortcut key Ctrl + ', open the Command window line,' this button on the TAB key above, I just started not found, hehe. Enter the following and return to:
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 '
4. After restarting Sublime Text 2, it is possible to find a menu item in the Preferences menus under the package Control.
5. Now that the Gosublime plugin is installed, press and hold ctrl+shilft+p a dialog box will pop up.
Enter the Install Enter dialog box to pop up an installation package
If enter gosublime Select Gosublime Enter
Enter go build to select Enter (this is optional)
Done, Gosublime installed successfully.
6. Install Gocodebelow,
Open the console and enter the following:
Go get github.com/nsf/gocode
Go install github.com/nsf/gocode
You can also go to GitHub to download https://github.com/nsf/gocode.git (to install Google's git version management tool)
After the installation is complete, we can find an extra Gocode file in the Go/bin directory. (Be sure to put it in the bin directory)
7. Modify the Gosublime configuration: Under the Preferences menu, locate the package Settings, find the gosublime, and then find Settings-default. Re-open the file, add the following configuration, and save:
Well, so far, the development environment has been built.
Open Sublime Text 2 , create a new helloworld.go, and write the following code:
The time to witness the Go Code auto prompt
Enter a P
Carriage return (enter key)
The main method, the package is automatically generated for you.
Here is an example of printing:
Pressing the shortcut key below the Ctrl + B interface will appear as follows:
Enter Go build hello.go
Run, also press the shortcut key Ctrl + B below the interface will appear below, enter the Hello return.
Well, by now, the development environment has been set up, I hope you will also learn the language of go.
Novice Entry Reference:
The starter API is the best new starter document I've ever seen and I want go to flourish.
The above content is reproduced http://blog.csdn.net/love_se/article/details/7754274
But Linux requires a flexible configuration.
Environment Variables Section:
Modify /etc/profile or. bashrc or. Bash_profile
Join as a JDK
Export Java_home=/usr/lib/jvm/java-7-sun
Export JRE_HOME=${JAVA_HOME}/JRE
Export Classpath=.:${java_home}/lib:${jre_home}/lib
Export Path=${java_home}/bin: $PATH