In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of "sample Analysis of basic types and constant usage of Go language". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Overview
In the Go programming language, data types are used to declare functions and variables. The emergence of data types in order to divide the data into the need to use big data need to apply for large memory, so that the column can fully use memory.
There are several data types by category: numeric types
Boolean type
Bool: Boolean values can only be constant true or false, and the default value is false.
String type
String: the encoding is unified as the UTF-8 encoding identification Unicode text, and the default value is an empty string.
Integer (default is 0)
Uint8: unsigned 8-bit integers (0-255)
Uint16: unsigned 16-bit integer (0 ~ 65535)
Uint32: unsigned 32-bit integer (0 ~ 4294967295)
Uint64: unsigned 64-bit integer (0 ~ 18446744073709551615)
Int8: signed 8 bit integer (- 128127)
Int16: signed 16-bit integer (- 32768 ~ 32767)
Int32: signed 32-bit integer (- 2147483648 ~ 2147483647)
Int64: signed 64-bit integer (- 9223372036854775808 ~ 9223372036854775807)
Floating point (default is 0)
Float32:IEEE-754 32-bit floating point number
Float64:IEEE-754 64-bit floating point number
Complex64:32 bit real number and imaginary number
Complex128:64 bit real number and imaginary number
Other numerical types
Byte: similar to uint8
Rune: similar to int32
Uint:32 or 64-bit
Int: same size as uint
Uintptr: unsigned integer, used to store a pointer
Derived type pointer type (Pointer)
Array type
Structured types (struct)
Channel type (chan)
Function type (func)
Slice Type (slice)
Interface type (interface)
Overview of Map type (map) variables
A constant is a constant value relative to a variable and cannot be modified again, such as pi.
A single variable declares const pi = 3.141592const e = 2.718281
The declaration of a constant is very similar to that of a variable, except that var is replaced with const.
Multiple variables declare const (pi = 3.141592 e = 2.718281)
Constants can be used for array declarations because they are determined at compile time
Const size = 4var arr [size] int "Analysis of Go language basic types and constant usage examples" ends here. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.