当前位置:网站首页>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
边栏推荐
- Leetcode-128 最长连续序列
- js找出数字在数组中下一个相邻的元素
- R语言ggplot2可视化:gganimate创建动态柱状图动画(gif)、在动画中沿给定维度逐步显示柱状图、enter_grow函数和enter_fade函数控制运动内插退出(渐变tweening)
- 记一次 .NET 差旅管理后台 CPU 爆高分析
- 精耕渠道共谋发展 福昕携手伟仕佳杰开展新产品培训大会
- R语言caTools包进行数据划分、scale函数进行数据缩放、class包的knn函数构建K近邻分类器、table函数计算混淆矩阵
- What designs are needed in the architecture to build a general monitoring and alarm platform
- docker 部署mysql8.0
- Salesmartly has some tricks for Facebook chat!
- Lumiprobe Lumizol RNA 提取试剂解决方案
猜你喜欢
Halcon image calibration enables subsequent image processing to become the same as the template image
Improve yolov5 with gsconv+slim neck to maximize performance!
Leetcode203 移除链表元素
毕业季 | 华为专家亲授面试秘诀:如何拿到大厂高薪offer?
关于企业中台规划和 IT 架构微服务转型
每周推荐短视频:警惕“现象”与“问题”相互混淆
What designs are needed in the architecture to build a general monitoring and alarm platform
斯坦福、Salesforce|MaskViT:蒙面视觉预训练用于视频预测
12 data dimensioning processing methods
Leetcode203 remove linked list elements
随机推荐
12 data dimensioning processing methods
为什么独立站卖家都开始做社交媒体营销?原来客户转化率能提高这么多!
Graduation summary
Leetcode-141环形链表
R language ggplot2 visualization: visualize the line graph and add customized Y-axis label information to the line graph using the labels function
搭建一個通用監控告警平臺,架構上需要有哪些設計
关于企业中台规划和 IT 架构微服务转型
Privacy sandbox is finally coming
Leetcode203 remove linked list elements
LeetCode-21合并两个有序链表
Altair HyperWorks 2022软件安装包和安装教程
Mysql database of easyclick
Regular expression
搭建一个通用监控告警平台,架构上需要有哪些设计
How to operate technology related we media well?
Viewing the whole ecology of Tiktok from a macro perspective
OpenAI|视频预训练 (VPT):基于观看未标记的在线视频的行动学习
Case study on comprehensive competitiveness of principal components
R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用n.of.lines参数指定显示的病例数
数据库基础:select基本查询语句