当前位置:网站首页>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
边栏推荐
- 字节跳动数据平台技术揭秘:基于 ClickHouse 的复杂查询实现与优化
- Privacy sandbox is finally coming
- 解决方案:可以ping别人,但是别人不能ping我
- Golang error handling
- Stanford, salesforce|maskvit: masked vision pre training for video prediction
- ACM mm 2022 video understanding challenge video classification track champion autox team technology sharing
- R语言ggplot2可视化:gganimate创建动态柱状图动画(gif)、在动画中沿给定维度逐步显示柱状图、enter_grow函数和enter_fade函数控制运动内插退出(渐变tweening)
- R language uses follow up of epidisplay package Plot function visualizes the longitudinal follow-up map of multiple ID (case) monitoring indicators, and uses n.of The lines parameter specifies the num
- 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
- 6款红黄黑榜摄像头评测:谁最安全?谁画质好?从此让你不再踩雷
猜你喜欢

6款红黄黑榜摄像头评测:谁最安全?谁画质好?从此让你不再踩雷

宏观视角看抖音全生态

Three.js学习-相机Camera的基本操作(了解向)

Memo - about C # generating barcode for goods

Lumiprobe 生物分子定量丨QuDye 蛋白定量试剂盒

Leetcode-128 最长连续序列

What designs are needed in the architecture to build a general monitoring and alarm platform

1. "Create your own NFT collections and publish a Web3 application to show them." what is NFT

Solution: you can ping others, but others can't ping me

Unity learning fourth week
随机推荐
斯坦福、Salesforce|MaskViT:蒙面视觉预训练用于视频预测
R语言epiDisplay包ordinal.or.display函数获取有序logistic回归模型的汇总统计信息(变量对应的优势比及其置信区间、以及假设检验的p值)、write.csv函数保存csv
研究了11种实时聊天软件,我发现都具备这些功能…
Must see, time series analysis
Principal component calculation weight
1. "Create your own NFT collections and publish a Web3 application to show them." what is NFT
Li Kou daily question - Day 32 -1232 Dotted line
毕业季 | 华为专家亲授面试秘诀:如何拿到大厂高薪offer?
app发版后的缓存问题
Write it down once Net travel management background CPU Explosion Analysis
R语言ggplot2可视化:gganimate包transition_time函数创建动态散点图动画(gif)、shadow_wake函数配置动画的渐变效果(gradual falloff)拖尾效应
Privacy sandbox is finally coming
After studying 11 kinds of real-time chat software, I found that they all have these functions
字节跳动数据平台技术揭秘:基于 ClickHouse 的复杂查询实现与优化
Lefse analysis
如何使用物联网低代码平台进行个人设置?
PriorityQueue的用法和底层实现原理
Viewing the whole ecology of Tiktok from a macro perspective
R语言caTools包进行数据划分、scale函数进行数据缩放、class包的knn函数构建K近邻分类器、table函数计算混淆矩阵
How to manage 1000 anchors by one person?