Go Language Programming Basics 2

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

A Go language basic type

1 Boolean type: BOOL Length: 1 bytes. Value range: true, False. Precautions: Do not use numbers instead. 2 Shaping: Int/uint Depending on the operational platform, 32-bit operating system 32-bit, 64-bit operating system 64-bit. 3 8-bit integer: int8/uint8 Length 1 bytes. Value range: -128~127/0~255. 4 byte type: Byte (alias of Uint8) Uint8 is exactly the same as the byte type, which is an alias relationship. 5 16-bit integer: int16/uint16 Length: 2 bytes. Value range: -32768~32767/0~65535. 6 32-bit integer: Int32 (Rune)/UInt32 Length: 4 bytes. Range of values: 7 64-bit integer: Int64/uint64 Length: 8 bytes. Range of values: 8 floating-point type: Float32/float64 Length: 4 bytes/8 bytes Decimal places: Accurate to 7/15 decimal places 9 plural complex64/complex128 Length: 8/16 bytes 10 sufficient 32-bit or 64-bit integer type to hold the pointer: uintptr Length: associated with the operating system 11 other value types array, struct, string 12 reference types Slice, map, chan 13 Interface Type Interface 14 Function types Func
There are two aliases for the basic type of go language, byte and Rune. For readability, byte is literally used for byte operations, and Rune is used for Unnicode character manipulation.

Two types of 0 values

A value of 0 is not equal to a null value, but a variable is declared as a default value after a type, typically the default value of a value type is 0,bool to false,string as an empty string.

Declaration and assignment of three individual variables

Declaration format of a variable:var< variable name > < variable type > Variable assignment format:< variable name > = < expression > Simultaneous assignment of declarations: var < variable name > [Variable Type] = < expression >
Variable declaration var a int//variable assignment a = 123//variable declaration at the same time assignment var b int = 321//can omit type var c = 124//Variable declaration with the simplest form of assignment d: = 456

Note: The declaration of a global variable must use the var keyword

Declaration and assignment of more than four variables

var A, B, c, d = 1, 2, "a", 4//a, B, C, D: = 1, 2, "a", 4//function can also be used in this way, global variables cannot be used in the FMT. Println (a) fmt. Println (b) fmt. Println (c) fmt. Println (d)


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.