Date: January 1, July 18, 2014
1. Introduction The go programming language is an open-source project that makes programmers more efficient. Go is expressive, concise, clear, and efficient. Its parallel mechanism makes it easy to write multi-core and network applications, while novel type systems allow the construction of sexual modular programs. Go compilation to machine code is very fast, with convenient garbage collection and powerful runtime reflection. It is a fast, static type compilation language, but it feels dynamic, interpreted language. Go is the first class C language that implements simple (or simpler) parallel development and is cross-platform. 2. After the go language document is installed, you can run the go Doc command to view the document. For example, you can run the FMT command and enter go Doc FMT on the command line. To view the documentation of subdirectories in a package, use go Doc parent_package/son_directory, for example, go Doc hash/FNV 3. Differences between go and other languages. 1) Clear and concise: go tries to keep it small and elegant, and you can do a lot in just a few lines of code. 2) parallel: Go makes functions easily become very lightweight threads. These threads are called goroutines in go. 3) communication between channels is completed by channels. 4) Fast compilation and execution. The goal is as fast as C. The compilation time is calculated in seconds. 5) Security: when converting one type to another, explicit conversion is required and strict rules are followed. Go has garbage collection and does not require free () in go. The language will handle all this. 6) standard formatting: The go program can be formatted into almost any form that programmers want, however, the official format exists. Standard is also very simple: gofmt output is officially recognized format 7) type rear: type is behind the variable name, such as var a int to replace int A 8 in C) UTF-8: Everything is UTF-8, including strings and program code. You can use 9 in the Code.) Open-Source: The go license is completely open-source. 4. Hello World (1) package main (2) of the Go language) import "FMT" // formatted I/O/* print something */(3) func main () {(4) FMT. printf ("Hello, world! ") (5)} explanation: line (1) is required. All go files start with package <something>. The execution file that runs independently must be package main; line (2) needs to add the FMT package to main. In go, the package must appear before import. When the go language is executed, the main. line (4) of main () calls the function in the FMT package to print the string to the screen. The string is wrapped by "and can contain non-ASCII characters. The code comments in the go language are basically the same as those in other languages. Single-line comments are available // and multi-line comments are available/**/compile and run: Build: Go build helloworld. go. After compilation, an executable helloworld file is generated to run :. /helloworld or use the go run command to compile and run go run helloworld. for example, after compiling, run: or: