当前位置:网站首页>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 it down once Net travel management background CPU Explosion Analysis
- How to operate technology related we media well?
- Go Technology Daily (2022-02-14) - go language slice interview real questions 8 consecutive questions
- 【AGC】如何解决事件分析数据本地和AGC面板中显示不一致的问题?
- Halcon图片标定,使得后续图片处理过后变成与模板图片一样
- Clean up system cache and free memory under Linux
- Popular science: what does it mean to enter the kernel state?
- 太爱速M源码搭建,巅峰小店APP溢价寄卖源码分享
- Lumiprobe biomolecular quantification - qudye Protein Quantification Kit
- 斯坦福、Salesforce|MaskViT:蒙面视觉预训练用于视频预测
猜你喜欢

OpenAI|视频预训练 (VPT):基于观看未标记的在线视频的行动学习

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

Leetcode-141环形链表

Li Kou daily question - Day 32 -589 N × Preorder traversal of tree

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

斯坦福、Salesforce|MaskViT:蒙面视觉预训练用于视频预测

Memo - about C # generating barcode for goods

Five degrees easy chain enterprise app is newly upgraded

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

关于企业中台规划和 IT 架构微服务转型
随机推荐
数据库基础:select基本查询语句
如何运营好技术相关的自媒体?
Leetcode-141环形链表
Mysql database of easyclick
The R language uses the tablestack function of epidisplay package to make statistical summary tables (descriptive statistics based on the grouping of target variables, hypothesis testing, etc.). If th
How to realize the applet in its own app to realize continuous live broadcast
R语言使用epiDisplay包的dotplot函数通过点图的形式可视化不同区间数据点的频率、使用pch参数自定义指定点图数据点的形状
Relational database management system of easyclick
Qfile read / write file operation in QT
字节跳动数据平台技术揭秘:基于 ClickHouse 的复杂查询实现与优化
How to find the optimal learning rate
docker 部署mysql8.0
Implementation of converting PCM file to WAV
如何在自有APP内实现小程序实现连麦直播
LeetCode-21合并两个有序链表
Memo - about C # generating barcode for goods
关于企业中台规划和 IT 架构微服务转型
Technology implementation and Architecture Practice
毕业季 | 华为专家亲授面试秘诀:如何拿到大厂高薪offer?
【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决