Go language foundation and environment configuration

GoLang

  • Is a compiled language.
  • Go language is a programming language designed for another attempt, a significant improvement over C-like language, which not only allows you access to the underlying operating system, also provides a powerful network programming and concurrent programming support. Go numerous uses language can network programming, system programming, concurrent programming, distributed programming.
  • And C language syntax is similar,
    • -Go strict grammatical rules of the language, there is no ambiguity, no more black magic variation of usage. People write any code are basically the same, which makes the Go language is easy to learn. Give up some "flexibility" and "freedom" in exchange for better maintainability, I think it is worth it.
    • It supports high concurrency better.
    • Garbage collection has been a problem. Go solve the language better.
    • Go language is born in the era of multi-core and network background native support for concurrent programming languages. Go language support concurrent native from the bottom, without third-party libraries, developers can easily decide how to use CPU resources when writing programs.

Go for what language do

  • Block chain technology of choice go Language
  • Go language standard library (commonly referred to as the battery comes language), provides a clear and common interface building blocks, comprising I / O operation, the processing of text, image, cryptography, and other networks and distributed applications, and It supports many standardized file formats and codec protocols

go language installation

  • The default path is under mac: / usr / local download path: https: //golang.google.cn/dl/
  • Set Environment Variables
$ vim ~/.bash_profile
$ export GOPATH=$HOME/go

Go language syntax

  • Languages ​​do not need to go end with a semicolon, unless there are multiple statements in a row, separated by a statement

Declaring Variables

  • go is statically typed language, variables are clear types.
var var_name type
- type包括 bool、string、int、int8、int32、int64
- uint、uint8、uint16、uint32、uint64、uintptr
- byte // uint8 的别名
- rune // int32 的别名 代表一个 Unicode 码
- float32、float64
- complex64、complex128
  • When a variable is declared, it is automatically given the value of zero types: int is 0, float to 0.0, bool is false, string is an empty string, the pointer is nil and the like. All memory is initialized in Go's.
  • Camel naming variables follow the nomenclature, that the first word lowercase, first letter of each new word is capitalized, such as: numShips and startDate.
Published 299 original articles · won praise 129 · views 80000 +

Guess you like

Origin blog.csdn.net/weixin_32393347/article/details/104603334