当前位置:网站首页>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
边栏推荐
- 洞态在某互联⽹⾦融科技企业的最佳落地实践
- 透过华为军团看科技之变(六):智慧公路
- 《Go题库·16》读写锁底层是怎么实现的
- 用WPF写一款开源方便、快捷的数据库文档查询、生成工具
- OpenAI|视频预训练 (VPT):基于观看未标记的在线视频的行动学习
- R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用n.of.lines参数指定显示的病例数
- Li Kou daily question - Day 32 -589 N × Preorder traversal of tree
- Leetcode-128 最长连续序列
- Li Kou daily question - Day 32 -1232 Dotted line
- 为什么独立站卖家都开始做社交媒体营销?原来客户转化率能提高这么多!
猜你喜欢

为什么独立站卖家都开始做社交媒体营销?原来客户转化率能提高这么多!

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

关于企业中台规划和 IT 架构微服务转型

540. Single element in ordered array / 1684 Count the number of consistent strings

Image acquisition and playback of coaxpress high speed camera based on pxie interface

洞态在某互联⽹⾦融科技企业的最佳落地实践

Navicat premium 15 permanent cracking and 2021 latest idea cracking (valid for personal testing)

Must see, time series analysis

Weekly recommended short videos: be alert to the confusion between "phenomena" and "problems"

Halcon图片标定,使得后续图片处理过后变成与模板图片一样
随机推荐
Case study on comprehensive competitiveness of principal components
Database foundation: select basic query statement
Leetcode203 remove linked list elements
Openai video pre training (VPT): action learning based on watching unmarked online videos
R语言epiDisplay包ordinal.or.display函数获取有序logistic回归模型的汇总统计信息(变量对应的优势比及其置信区间、以及假设检验的p值)、write.csv函数保存csv
关于企业中台规划和 IT 架构微服务转型
Write it down once Net travel management background CPU Explosion Analysis
磁盘的基本知识和基本命令
2020,最新手机号码手机验证正则表达式,持续更新
Privacy sandbox is finally coming
OpenAI|视频预训练 (VPT):基于观看未标记的在线视频的行动学习
R语言ggplot2可视化:gganimate创建动态柱状图动画(gif)、在动画中沿给定维度逐步显示柱状图、enter_grow函数和enter_fade函数控制运动内插退出(渐变tweening)
Implement a Prometheus exporter
【AGC】如何解决事件分析数据本地和AGC面板中显示不一致的问题?
宏观视角看抖音全生态
Qfile read / write file operation in QT
ACM MM 2022视频理解挑战赛视频分类赛道冠军AutoX团队技术分享
R语言使用dplyr包的transmute函数计算dataframe数据中的指定数据列的移动窗口均值、使用ggplot2包可视化移动均值与原始数据的折线图
How does factor analysis calculate weights?
AI training speed breaks Moore's law; Song shuran's team won the RSS 2022 Best Paper Award