This is a creation in Article, where the information may have evolved or changed.
Preface:
in recent years, a variety of new computer programming languages are constantly appearing, which for our program ape, is a very happy thing ah. Especially for the same as the author of the passionate people, the update is extremely happy. And the last chance I came into contact with the go language, so I can not help but the beautiful grammar and write the text here. In fact, the go language has appeared a few years ago, for many people, perhaps not something new, and for like the author just contact or first heard of people, is really new things, then in the end how the Go language appears? Why does it appear? It appeared again to solve what problem ... For the above a large number of problems, in this does not elaborate, this series is mainly case-based, for conceptual and language underlying design things will not involve a lot of, because this series is only interested in the amateur learning to get started, if you want to further study or study the go language, please read the Professional Go language books. Well, then let's go up together .
1. Start the first Go program
Hands-on Preparation:
download Go-- http://code.google.com/p/go/downloads/list
Choose a version from the above list for your platform installation, here I downloaded the version of the Windows (X86 32-bit) platform (if no special instructions for all the program compiled run based on this type of platform), for the Windows platform has installed version and decompression version for selection, Of course you can also choose the version of Linux or Mac platform.
Download install version installation (step by step follow the prompts, the environment is configured by default, and the following configuration procedures are not required, default path= " C:/go/bin ") or decompression version of the extract will be a folder, the folder will be stored in the go compiler and other go language development tools, assuming that the resulting folder is go, the contents of the directory structure such as:
:
Then you need to configure the environment variables:
1.GOROOT (the root directory of the Go installation package.) --Assuming the Go file price is on the D drive, then goroot= "D:\Go"
2.GOOS (operating system) and Goarch (CPU type)-goos= "Windows" goarch= "386"
3.path= "%goroot%\bin"--Specifies the go compiler execution path
The above is the most basic variable setting step, omitting the optional part.
When you are finished, open windows command-line cmd, execute: Go, enter after the following:
Indicates that the installation configuration was successful. Now we can start writing the first program.
With any editor, typing the following code:
Save As Hello.go and then use the command line to open the directory where the file is located, and enter the following compile command:
If there are no surprises, you will see the newly generated hello.exe in the current directory
Re-execution:
The first go program ran successfully.
- Author: Sirk
- Source: Http://www.cnblogs.com/vimsk
- This article is copyright to the author and the blog Park, Welcome to reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to the original link, otherwise reserves the right to pursue legal responsibility.
-
|