Go Language learning Note (i) [HelloWorld of Go language]

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed. Date: July 18, 2014
1. Introduction 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 multicore and Web applications, while the novelty type system allows the building of ᧄ modular programs. Go compiles to machine code very quickly, with convenient garbage collection and powerful runtime reflection.    It is a fast, statically typed compilation language, but it feels like a dynamic type, interpreted language. Go is the first class C language that implements a simple (or simpler) parallel development and a cross-platform.
2, go language documents after installing the Go language, its documentation can be viewed through the Go Doc command, such as viewing the FMT and entering the Go Doc fmt at the command line. If you want to view the documentation for subdirectories in a package, use Go Doc parent_package/son_directory, such as Go Doc HASH/FNV
3. Some differences between the go language and other languages 1) clear and concise: Go strives to remain small and graceful, and you can do many things in just a few lines of code 2) Parallel: Go makes the function very easy to be a very lightweight thread. These threads are called Goroutines 3 in Go) Channel:goroutines communication is done by Channel 4) Fast: Compile quickly and execute quickly. The target is as fast as C. Compile time in seconds 5) security: When converting one type to another, explicit conversions are required and strict rules are followed. Go has garbage collection, no free () in Go, language handles it all 6) standard format: Go programs can be formatted as programmers want (almost) any form, but the official format is there. The standard is also very simple: the output of GOFMT is officially recognized format 7) Type post: Type after the variable name, such as var a int, instead of int a 8 in C UTF-8: Anywhere is UTF-8, including the string and the program code. You can use 9 in code) Open Source: Go License is fully open source
4, go language Hello world      (1) package main       (2) import "FMT"//Implement formatted i/o  &NBSP ;        /* Print something */      (3) Func main () {       (4)       FMT. Printf ("hello,world!")        (5)}      explain:    (1) line is required, all go files begin with the package <something>, For standalone run executable files must be package main;    (2) line need to add the FMT packet to main, in go, the packages must appear before the import, when the Go language executes, the first call Main.main ()     (4) line invokes a function in the FMT package to print the string to the screen, the string is "wrapped, and can contain non-ASCII characters."     Go language code comments are basically consistent with other languages, single-line comments available//, multiline comments Available/*  */    compiling and running:        BUILD: Go Build Helloworld.go, build HelloWorld executable file after compilation         run:./helloworld        Or use the Go Run command to compile and run, go run helloworld.go    For example:        compile:           Run:            or: &NBSp    

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.