golang中的variable和data types
https://golangbyexample.com/variables-in-golang-complete-guide/#What_is_variable
问题
go里面的string为什么是不可变类型的
go里面 1 && 1 语法为什么错误了?
variables
declare variables
var var_name var_type
没有初始赋值的会使用the default value of that type which is also known as zero value of that type
var <variable_name> <type> = <value>
:= operator
data types
import (
“fmt”
“reflect”
“unsafe”
)
获取大小和类型:unsafe.SizeOf 和 reflect.TypeOf
不过从这两个方法的命名上我吐血了,还是太年轻了啊
一、basic types
整数
有符号整型
int
int8
int16
int32
int64
无符号整型
uint
uint8
uint16
uint32
uint64
floats
float32
float64
float64 is the default float type. When you initialize a variable with a decimal value and don’t specify the float type, the default type inferred will be float64.
Complex Numbers
complex64
complex128
Byte
byte是int8的别名
go里面没有char
var b byte = ‘a’
rune
int32
string
string is a read only slice of bytes in golang.
String can be initialized in two ways
s1 := “this is a string”
s2 := `this is a string`
Booleans
var b bool = true
var b2 bool = false
二、composite types(复合类型)
Arrays
参考图表
golang中的variable和data types相关推荐
- ajax jqxhr,jquery ajax 之 jqXHR 和 Data Types详解
jQuery 发送的所有 Ajax 请求,内部都会通过调用 $.ajax() 函数来实现.通常没有必要直接调用这个函数,可以使用几个已经封装的简便方法,如$.get()和.post().如果你需要用到 ...
- golang的new函数_new()和make()函数以及Golang中的示例
golang的new函数 In Golang, to allocate memory, we have two built-in functions new() and make(). 在Golang ...
- 记一次golang中sync.Map并发创建、读取的问题
记一次golang中sync.Map并发创建.读取的问题 cunfate https://www.jianshu.com/p/f472e79909bc 背景: 我们有一个用go做的项目,其中用到了z ...
- Golang中log日志包的使用
文章目录 1.前言 2.log包介绍 3.log包的使用 3.1 日志输出方法 3.2 自定义创建日志对象 3.3 封装自定义日志包 3.4 log包进一步解析 1.前言 作为后端开发人员,日志文件记 ...
- 【12c】扩展数据类型(Extended Data Types)-- MAX_STRING_SIZE
[12c]扩展数据类型(Extended Data Types)-- MAX_STRING_SIZE [12c]扩展数据类型(Extended Data Types)-- MAX_STRING_SIZ ...
- Golang中Buffer高效拼接字符串以及自定义线程安全Buffer
本文原创文章,转载注明出处,博客地址 https://segmentfault.com/u/to... 第一时间看后续精彩文章.觉得好的话,顺手分享到朋友圈吧,感谢支持. Go中可以使用"+ ...
- golang中并发sync和channel
golang中并发sync和channel chenbaoke · 2014-12-08 13:00:01 · 19151 次点击 · 预计阅读时间 5 分钟 · 不到1分钟之前 开始浏览 这是一个创 ...
- UiPath Level 1-Lesson 2. Variables Data Types Introduction
学习大纲 界面布局 添加活动 (Activities) 使用变量 使用流程图 (Flowcharts) 或序列 (Sequences) 1. 界面布局 Ribbon Activities Workfl ...
- golang 中 map 转 struct
golang 中 map 转 struct package mainimport ("fmt""github.com/goinggo/mapstructure" ...
最新文章
- DataPipeline |《Apache Kafka实战》作者胡夕:Apache Kafka监控与调优
- IN和EXISTS的性能对比结论
- 使用Dezender对zend加密后的php文件进行解密
- 一款监控网络状态的好工具- Smokeping
- 小程序和app用什么样的服务器,小程序和APP的本质区别是什么?哪个更值得开发?...
- 怎样使set现程变得安全_使不安全变得更加安全
- 计算机图形学论文_论图计算
- AOJ 6.Hero In Maze
- (王道408考研数据结构)第四章串-第二节:串的模式匹配算法(朴素和KMP)
- python whl安装 缺少dll 查看具_解决Python安装时报缺少DLL问题【两种解决方法】
- Linux下用户、组、权限操作
- Vue简介及HelloWord编写
- 188. 买卖股票的zui佳时机 IV(JavaScript)
- wordpress连接mysql数据库_wordpress远程连接mysql数据库方法
- Zookeeper之数据同步原理
- 计算机一进制一加一等于一,1加1等于几所有答案_灯谜一加一打一字的答案
- java多个文件压缩成zip文件
- 怎么把短视频做成表情包?短视频制作gif只需三步
- 微信小助手 for mac(WeChatPlugin)使用攻略
- [c/c++]trivial/POD类型和standard layout
热门文章
- C++——random库中的uniform_int_distribution
- 【ICLR2019】Oral 论文汇总
- 算法—两个有序数组的中位数 Median of Two Sorted Arrays
- 0923html测试
- 02-mysql数据库的特点-卸载-安装-配置-mysql5.5版本
- -bash: mysql: command not found解决方法(zabbix监控mysql失败)
- codeforce 804B Minimum number of steps
- 八年数据库之路的感悟
- 在Ubuntu下面编译WizNote Qt Project
- Oracle 11g安装(window)的7个服务