This is a creation in Article, where the information may have evolved or changed.
http://studygolang.com/articles/1348
1 integers
In the Go language, if you do not add a special prefix, it is a 10 binary representation, for example: "100"
Integers can be used directly in exponential form, for example: "1E9", meaning 1 * (10^9), 1 times 10 of 9
The addition and subtraction of integers with the + and-number, multiplication with the * number, division with/number, the resulting quotient is an integer, for example 5/2 = 2, while the% number is the redundancy (modulo), for example 5 2 = 1
In the Go language, integer types are divided into signed integers and unsigned integers, followed by their respective lengths, respectively, into 4 types.
Signed Integral type int8 int16 int32 int64
Non-signed integer uint8 uint16 uint32 UINT 64
In addition to the default type int and uint, which are currently 32 bits, the future may become 64-bit
There are also 2 special integer aliases, which are related to strings, namely: Byte (Uint8), Rune (Int32), which is interpreted when strings are related
Integer comparison with >/</= =/! =/<=/>=, the result is Boolean type, True or False
Bitwise operations & (and), | (or), ^ (XOR), &^ (and non),<< (left),>> (shift right)
XOR itself, equivalent to the inverse code, such as ^1 = -2 (PS: (^-1) + 1 = 1 complement)
2 floating point
In the Go language, floating-point numbers are divided into two types, float32 and float64, in accordance with the regulations of IEEE 754.
A floating-point number that is only part of the integer, to be marked with a decimal point, such as 1.0 for a floating-point 1
For integer literals and floating-point literals, go is automatically converted from integer to floating-point or floating-point numbers, as used.
3 plural
Basically rarely used, briefly introduced under
In the Go language, the plural is divided into complex64 and complex128, which can be expressed in 0+1i format.
4 bool
In the Go language, the Boolean value is of type bool and the value is true or False
Boolean can do 3 logical operations,&& (logical AND), | | (logical OR),! (Logical non)
In logical expressions, the Go language also supports short-circuit judgment
The value of the Boolean type does not support other types of conversions
5 string
In the Go language, the smallest unit of composing a string is a character, the smallest unit stored is a byte, and the string itself does not support modification.
bytes are the smallest unit of data storage, each byte of data can be expressed in integers, such as a byte of the stored character A, the actual storage is 97 rather than the character of the glyph, the actual stored content is represented by the type of a number, called a byte.
Characters are UTF-8 encoded Unicode characters, Unicode defines a unique code value (that is, an integer) for each character instead of a glyph, for example, the character A is the 97th character in the Unicode character Map, so its corresponding value is 97, which means that for the go language processing characters, 97 and A refers to the character a, and the Go language uses the numeric value to refer to the character as the Rune type.
Usually when Unicode represents a character, it is usually denoted by "u+" followed by a set of hexadecimal digits, such as the character A is usually represented by u+0061.
In the Go language, if you directly follow the character's glyph, you can use a single quotation mark (') to denote, for example ' a ', can also be represented by the code value, the \xnn, \unnnn, \unnnnnnnn format, each N represents a number. For example, the character a can be \x61 or \u0061 or \u00000061
In the Go language, you can represent strings in two ways, one enclosed in double quotation marks ("), and can contain escape characters. The other is the use of anti-quotation marks ('), which can contain formatting characters such as newline, feeling a bit like the heredoc of other languages.
Because the smallest unit that makes up a string is a character, and the smallest unit of storage is a byte, and for a string traversal, it is only a total of less than 1 byte characters (that is, the code value is less than 256), which can be traversed directly or transferred to a byte slice, which consists of more than 1 byte characters. The safest approach is to convert to rune slices.