A, Go preparatory language learning

1, the direction of learning

  • Block chain R & D engineers

  • Go server / game software engineer

  • Golang distributed / cloud computing software engineer

 

2, Golang applications

  • Application development block chain

    Block chain technology, referred to as BT (Blockchain technology). Also known as distributed technology books, is an Internet database technology, which is characterized by decentralized, open and transparent, so that everyone can participate in the database record.

  • Back-end server references

    As the US group supporting the background traffic program, Xian Xia Road game server

  • Cloud computing / cloud service back-office applications

    Shengtai Yun CDN (content delivery network), push cloud services and news Jingdong Jingdong Distributed File System

 

3, Golang birth of reasons

1) computer hardware technology updates frequently, performance improved quickly. The current mainstream programming language developed significantly behind the hardware, can not reasonably take advantage of multi-core CPU upgrade system software performance.

2) increasing complexity of software systems, increasing maintenance costs, the current lack of a sufficiently simple and efficient programming language. [Existing programming language: 1. 2. The style is not uniform enough computing power to handle large 3. Concurrent not good enough in].

3) Many enterprise operation and maintenance c / c ++ project, c / c ++ program running speed though fast, but the compilation speed is very slow indeed, but there are still a series of problems to be solved a memory leak.

 

4, Golang language features

Go language to ensure the safety and performance can not only reach the statically compiled language, but also to achieve high efficiency dynamic language development and maintenance, and use an expression to describe the Go language: Go = C + Python, both the C language description Go static language program running speed, while maintaining the rapid development of dynamic language Python.

  • Inherited from the C language, a lot of ideas, including expression syntax, control structures, basic data types, call parameters by value, pointer and so on, but also retained the same compiler and C language implementation and weakening pointer.

testPtr func (int * num) { 
     * num = 20 
 }
  • Introduction of the concept package for organizational structure of the program, a file Go language to be attributable to an a package, and can not exist alone.

  • Garbage collection, memory, automatic recovery, developers do not need to manage

  • Natural concurrent (an important feature)

    (1) from the level of support concurrent language, simple

    (2) goroutine, lightweight thread, can achieve high concurrent processing, efficient use of multiple cores.

    (3) CPS concurrency model (Communicating Sequential Processes) based on achieving

  • Absorbing pipe communication mechanism, a Go language-specific channel via conduit pipe channel, can communicate with each other among different goroute.

  • Function can return multiple values

    // return function and achieve the same time, the difference 
     FUNC getSumAndSub (int N1, N2 int) (int, int) { 
         SUM: = N1 + N2 / O statements do not bring back the semicolon 
         Sub: N1 = -n2 
         return SUM, Sub 
     }    
  • New innovations: for example, slice slice, defer execution delay

 

5, Golang in Windows and Linux installation steps

  • Windows

    Download the SDK go1.9.2.windows-amd64.zip, directly extract. Window must be configured three environment variables After configuring the environment variables, cmd run go version displays the version that is installed successfully.

    GOROOT Specify the installation path of the SDK
    PATH Specify the SDK bin directory
    Gofatः Work path go project
  • Linux

    Download the SDK go1.9.2.linux-amd64.tar.gz, unzip, configure the system environment variables, source / etc / profile, perform go version displays the version that is installed successfully

vim / etc / Profile 
 Export GOROOT = / opt / ### Go SDK installation directory 
 Export the PATH = $ the PATH: $ GOROOT / bin 
 Export GOPATH the HOME = $ / goproject

  

Guess you like

Origin www.cnblogs.com/hucheng1997/p/11594298.html