Go a little every day fundamentals of grammar and language --Go language primitive data types
A, Go language basic grammar
Part I talked about the Go language to explain the basic structures of the language related to Go, the measure would go to talk about the basic grammar of the language. Go language program by a plurality of markers, for example: keywords, identifiers, constants, symbols, strings.
Line separator - row represents the end of a sentence, without having to write ";." Of course, you can write multiple statements on one line, and use ";" No distinction, but not recommended to write code development.
Comment on this article is not to say.
Identifier
If the variable is the first hurdle to get started shell, it can be said, the identifier is the first threshold development language.
Identifier, Officially explanation: for naming the variables, type of program entities. It includes an identifier of the features: a fact or a plurality of letters (A ~ Z and a ~ z) numbers (0 to 9), _ underlined sequence composition, but the first character must be a letter underlining not huo is a number.
My personal understanding: identifier can be understood as the language already booked good words (keywords) and (development programmer or user) defined by the value of their own programmers (above mentioned entities).
Keyword
Here a list of what can be analogy shell in time, case, if, default, etc.
25 keywords and reserved words:
break | default | func | interface | select |
case | defer | go | map | struct |
chan | else | goto | package | switch |
const | fallthrough | if | range | type |
continue | for | import | return | where |
Go language as well as 36 predefined identifiers
append | bool | byte | cap | close | complex | complex64 | complex128 | uint16 |
copy | false | float32 | float64 | imag | int | int8 | int16 | uint32 |
int32 | int64 | iota | only | make | new | nil | panic | uint64 |
println | real | recover | string | true | uint | uint8 | unitptr |
go by the general language program keywords, constants, variables, operators, type, and functions; may be used to program these delimiters: parentheses (), brackets [] and braces {}; programs may be used to these punctuation: ,,,;,: and ....
Two, Go language data types
In the Go language, the data type used to declare functions and variables. Appears to the data type of data into different memory sizes required data, programming time needed when it is large data need to apply large memory, can take advantage of the memory.
Go language data types are: bool type, numeric type, string type, derived type
Boolean
Boolean values can only be constants true or false. A simple example: var b bool = true.
Numeric
Into integer, floating point, and the corresponding float int
Go language support integer and floating point numbers, and native support complex, wherein the position calculation using complement
Integer
1, uint family (unsigned int)
- 8-- ~ range: 0 ~ 255
- 16-- ~ range: 0 to 65535
- 32-- ~ range: 0 to 2 ^ 32-1
- 64-- ~ range: 0 to 2 ^ 64-1
2, int family (signed integer)
- 8-- ~ range: -127 to 128
- 16-- ~ range: -32768 to 32767
- 32-- ~ range: -2 ^ 31 to 2 ^ 31-1
- 64-- ~ range: -2 ^ 63 to 2 ^ 63-1
Float
float32 - IEEE-754 32-bit floating point number
float64 - IEEE-754 64-bit floating point number
complex64--32 bit real and imaginary
complex128--64 bit real and imaginary
Other types of digital
byte-- with similar uint8
rune-- with similar int32
uintptr-- unsigned integer, pointer storage