当前位置:网站首页>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
边栏推荐
- Excel之VBA简单宏编程
- Leetcode-128 最长连续序列
- The R language cartools package divides the data, the scale function scales the data, the KNN function of the class package constructs the k-nearest neighbor classifier, and the table function calcula
- Viewing the whole ecology of Tiktok from a macro perspective
- 研究了11种实时聊天软件,我发现都具备这些功能…
- code
- Implement a Prometheus exporter
- Leetcode203 移除链表元素
- 如何运营好技术相关的自媒体?
- Graduation summary
猜你喜欢

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

How to manage 1000 anchors by one person?

Go Technology Daily (2022-02-14) - go language slice interview real questions 8 consecutive questions

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

宏观视角看抖音全生态

LeetCode-21合并两个有序链表

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

Leetcode-141环形链表

Altair HyperWorks 2022软件安装包和安装教程

搭建一个通用监控告警平台,架构上需要有哪些设计
随机推荐
微服务大行其道的今天,Service Mesh是怎样一种存在?
Lumiprobe bifunctional crosslinker sulfo cyanine 5 bis NHS ester
How to find the optimal learning rate
搭建一個通用監控告警平臺,架構上需要有哪些設計
Navicat Premium 15 永久破解和2021版本最新IDEA破解(亲测有效)
Introduction to easyclick database
【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决
Halcon image calibration enables subsequent image processing to become the same as the template image
12 data dimensioning processing methods
JS find the next adjacent element of the number in the array
R语言使用epiDisplay包的tableStack函数制作统计汇总表格(基于目标变量分组的描述性统计、假设检验等)、不设置by参数则计算数据框指定数据列范围的基础描述性统计信息
LeetCode-21合并两个有序链表
Leetcode-83 delete duplicate elements in the sorting linked list
Viewing the whole ecology of Tiktok from a macro perspective
Graduation summary
Clean up system cache and free memory under Linux
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)
3、《创建您自己的NFT集合并发布一个Web3应用程序来展示它们》在本地铸造 NFT
毕业季 | 华为专家亲授面试秘诀:如何拿到大厂高薪offer?