当前位置:网站首页>GO语言基础数据类型
GO语言基础数据类型
2022-06-09 00:35:00 【一边学习一边哭】
前言
基础数据类型:
布尔类型
字符串类型
数字类型:int整数、float浮点数
派生类型:
数组类型、切片类型、指针类型、函数类型、Map类型、结构化类型(struct)、接口类型(interface)、Channel类型
数字类型
整数
有符号
| 类型 | 描述 |
| int8 | 有符号 8 位整型 (-128 到 127) |
| int16 | 有符号 16 位整型 (-32768 到 32767) |
| int32 | 有符号 32 位整型 (-2147483648 到 2147483647) |
| int64 | 有符号 64 位整型 (-9223372036854775808 到 9223372036854775807) |
无符号
| 类型 | 描述 |
| uint8 | 无符号 8 位整型 (0 到 255) |
| uint16 | 无符号 16 位整型 (0 到 65535) |
| uint32 | 无符号 32 位整型 (0 到 4294967295) |
| uint64 | 无符号 64 位整型 (0 到 18446744073709551615) |
特殊类型byte和rune。byte对应uint8,rune对应int32。
日常使用int和unit类型,位数取决于操作系统位数。
浮点数
| 类型 | 描述 |
| float32 | 单精浮点数 |
| float64 | 双精度浮点数 |
布尔类型
布尔类型顾名思义,要么是true,要么是false。
使用bool关键字来定义
var xxx bool字符串类型
语法上使用双引号定义字符串类型
var a string = "aaa"
b := "bbb"- 转义字符 \
- len()函数可以获取字符串长度
- 字符串隐藏了一个结束符‘\0’
边栏推荐
- Jz73: flipping word sequences
- Error Domain=NSCocoaErrorDomain Code=518 “The file couldn’t be saved because the specified URL type
- Form label
- AGV battery introduction
- Glamour chemistry glamour
- Jz77: print binary trees in zigzag order
- What are the categories of IOT network cards
- 连接池关键源码理解
- Redis persistence
- 【直播回顾】战码先锋第四期:轻松入门,成为媒体子系统贡献者
猜你喜欢

ThinkPHP2-RCE漏洞复现

What are cache avalanche, cache breakdown, and cache penetration?

Multiple registration methods for servlets

外包学生管理系统架构文档

Fastlane build version number increases automatically

Instrumental variables and two-stage least squares Stata

Pythia - vision and language research platform

A life and death journey of 2000+ orders on the same day when there is no supply of idle fish!

servlet的多种注册方式

关于Oracle数据库字符集的选择及乱码情况
随机推荐
Chapter 2 variables, data types, and operators
物联网卡的分类有哪些
关于Oracle数据库字符集的选择及乱码情况
opencv图像处理入门
PyTorch 源码解读之 BN & SyncBN:BN 与 多卡同步 BN 详解
How to select the correct message queue driver
矩阵 - 二维区域和检索 - 矩阵不可变,leetcode 304
js加入收藏
消息队列实战之基于 Redis 实现 消息队列系统及底层源码探究
operator
机器人学(二):动力学参数辨识
Final review of introduction to information security at Harbin Institute of Technology
JS add to collection
JZ73:翻转单词序列
Pythia - vision and language research platform
Yolox modifying focalloss
运算符
Fastdds awesome!!!
Method of downloading Baidu network disk data with command line
扁平化登录form页面