当前位置:网站首页>Go language self-study series | go language data type
Go language self-study series | go language data type
2022-07-01 18:55:00 【51CTO】
Video source :B standing 《golang Introduction to project practice [2021 newest Go Language course , There is no nonsense , Dry only ! Ongoing update ...]》
Organize the teacher's course content and test notes while studying , And share it with you , Infringement is deleted , Thank you for your support !
stay Go In programming language , Data types are used to declare functions and variables .
The emergence of data types is to divide the data into the required data types Memory size Different data , When programming, you need to use big data to apply for large memory , You can make full use of memory .
Go Languages have the following data types by category :
Serial number | Type and description |
1 | Boolean type Boolean values can only be constants true perhaps false. A simple example :var b bool = true. |
2 | Numeric type integer int And floating point float32、float64,Go The language supports integer and floating-point numbers , And support plural , The operation of the middle bit adopts complement . |
3 | String type : A string is a sequence of characters connected by a fixed length of characters .Go A string of strings is concatenated by a single byte .Go Language string byte use UTF-8 Code identification Unicode Text . |
4 | Derived type : Include :(a) Pointer types (Pointer)(b) An array type (c) Structured type (struct)(d) Channel type (e) Function type (f) Slice type (g) Interface type (interface)(h) Map type |
Numeric type
Go There are also architecture based types , for example :int、uint and uintptr.
Serial number | Type and description |
1 | uint8 Unsigned 8 An integer (0 To 255) |
2 | uint16 Unsigned 16 An integer (0 To 65535) |
3 | uint32 Unsigned 32 An integer (0 To 4294967295) |
4 | uint64 Unsigned 64 An integer (0 To 18446744073709551615) |
5 | int8 A signed 8 An integer (-128 To 127) |
6 | int16 A signed 16 An integer (-32768 To 32767) |
7 | int32 A signed 32 An integer (-2147483648 To 2147483647) |
8 | int64 A signed 64 An integer (-9223372036854775808 To 9223372036854775807) |
floating-point
Serial number | Type and description |
1 | float32 IEEE-754 32 Bit floating point number |
2 | float64 IEEE-754 64 Bit floating point number |
3 | complex64 32 Bit real number and imaginary number |
4 | complex128 64 Bit real number and imaginary number |
Other number types
Here are more types of numbers :
Serial number | Type and description |
1 | byte similar uint8 |
2 | rune similar int32 |
3 | uint 32 or 64 position |
4 | int And uint The same size |
5 | uintptr Unsigned integer , Used to store a pointer |
give an example
package main
import "fmt"
func a3() {
}
func main() {
var name string = "tom"
age := 20
b := true
fmt.Printf("name: %T\n", name)
fmt.Printf("age: %T\n", age)
fmt.Printf("b: %T\n", b)
a := 100
p := &a
fmt.Printf("p: %T\n", p)
a1 := [2]int{1, 2}
fmt.Printf("a1: %T\n", a1)
a2 := []int{1, 2, 3}
fmt.Printf("a2: %T\n", a2)
fmt.Printf("a3: %T\n", a3)
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
Running results
边栏推荐
- Write an open source, convenient and fast database document query and generation tool with WPF
- code
- 【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决
- 实例讲解将Graph Explorer搬上JupyterLab
- 用WPF写一款开源方便、快捷的数据库文档查询、生成工具
- Case study on comprehensive competitiveness of principal components
- 搭建一個通用監控告警平臺,架構上需要有哪些設計
- AI training speed breaks Moore's law; Song shuran's team won the RSS 2022 Best Paper Award
- Livedata postvalue will "lose" data
- Lumiprobe biomolecular quantification - qudye Protein Quantification Kit
猜你喜欢

微服务大行其道的今天,Service Mesh是怎样一种存在?

Five degrees easy chain enterprise app is newly upgraded

【AGC】如何解决事件分析数据本地和AGC面板中显示不一致的问题?

力扣每日一题-第32天-589.N×树的前序遍历

【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决

Halcon图片标定,使得后续图片处理过后变成与模板图片一样

搭建一個通用監控告警平臺,架構上需要有哪些設計

Leetcode-160相交链表

Viewing the whole ecology of Tiktok from a macro perspective

用WPF写一款开源方便、快捷的数据库文档查询、生成工具
随机推荐
After studying 11 kinds of real-time chat software, I found that they all have these functions
如何运营好技术相关的自媒体?
GameFramework食用指南
How to use the low code platform of the Internet of things for personal settings?
How to realize the bottom layer of read-write lock in go question bank 16
golang 错误处理
Lumiprobe非荧光炔烃丨EU(5-乙炔基尿苷)
R language ggplot2 visualization: gganimate package transition_ Time function to create dynamic scatter animation (GIF), shadow_ The wake function configures the gradient falloff tailing effect of the
R language uses the DOTPLOT function of epidisplay package to visualize the frequency of data points in different intervals in the form of point graph, and uses PCH parameters to customize the shape o
R language uses the transmute function of dplyr package to calculate the moving window mean value of the specified data column in dataframe data, and uses ggplot2 package to visualize the line graph b
How does factor analysis calculate weights?
Three. JS learning - basic operation of camera (learn from)
Mysql database of easyclick
Facebook聊单,SaleSmartly有妙招!
解决方案:可以ping别人,但是别人不能ping我
透过华为军团看科技之变(六):智慧公路
如何使用物联网低代码平台进行个人设置?
Thread forced join, thread forced join application scenarios
关于企业中台规划和 IT 架构微服务转型
Why do independent website sellers start to do social media marketing? The original customer conversion rate can be improved so much!