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相关推荐

  1. ajax jqxhr,jquery ajax 之 jqXHR 和 Data Types详解

    jQuery 发送的所有 Ajax 请求,内部都会通过调用 $.ajax() 函数来实现.通常没有必要直接调用这个函数,可以使用几个已经封装的简便方法,如$.get()和.post().如果你需要用到 ...

  2. golang的new函数_new()和make()函数以及Golang中的示例

    golang的new函数 In Golang, to allocate memory, we have two built-in functions new() and make(). 在Golang ...

  3. 记一次golang中sync.Map并发创建、读取的问题

    记一次golang中sync.Map并发创建.读取的问题  cunfate https://www.jianshu.com/p/f472e79909bc 背景: 我们有一个用go做的项目,其中用到了z ...

  4. Golang中log日志包的使用

    文章目录 1.前言 2.log包介绍 3.log包的使用 3.1 日志输出方法 3.2 自定义创建日志对象 3.3 封装自定义日志包 3.4 log包进一步解析 1.前言 作为后端开发人员,日志文件记 ...

  5. 【12c】扩展数据类型(Extended Data Types)-- MAX_STRING_SIZE

    [12c]扩展数据类型(Extended Data Types)-- MAX_STRING_SIZE [12c]扩展数据类型(Extended Data Types)-- MAX_STRING_SIZ ...

  6. Golang中Buffer高效拼接字符串以及自定义线程安全Buffer

    本文原创文章,转载注明出处,博客地址 https://segmentfault.com/u/to... 第一时间看后续精彩文章.觉得好的话,顺手分享到朋友圈吧,感谢支持. Go中可以使用"+ ...

  7. golang中并发sync和channel

    golang中并发sync和channel chenbaoke · 2014-12-08 13:00:01 · 19151 次点击 · 预计阅读时间 5 分钟 · 不到1分钟之前 开始浏览 这是一个创 ...

  8. UiPath Level 1-Lesson 2. Variables Data Types Introduction

    学习大纲 界面布局 添加活动 (Activities) 使用变量 使用流程图 (Flowcharts) 或序列 (Sequences) 1. 界面布局 Ribbon Activities Workfl ...

  9. golang 中 map 转 struct

    golang 中 map 转 struct package mainimport ("fmt""github.com/goinggo/mapstructure" ...

最新文章

  1. DataPipeline |《Apache Kafka实战》作者胡夕:Apache Kafka监控与调优
  2. IN和EXISTS的性能对比结论
  3. 使用Dezender对zend加密后的php文件进行解密
  4. 一款监控网络状态的好工具- Smokeping
  5. 小程序和app用什么样的服务器,小程序和APP的本质区别是什么?哪个更值得开发?...
  6. 怎样使set现程变得安全_使不安全变得更加安全
  7. 计算机图形学论文_论图计算
  8. AOJ 6.Hero In Maze
  9. (王道408考研数据结构)第四章串-第二节:串的模式匹配算法(朴素和KMP)
  10. python whl安装 缺少dll 查看具_解决Python安装时报缺少DLL问题【两种解决方法】
  11. Linux下用户、组、权限操作
  12. Vue简介及HelloWord编写
  13. 188. 买卖股票的zui佳时机 IV(JavaScript)
  14. wordpress连接mysql数据库_wordpress远程连接mysql数据库方法
  15. Zookeeper之数据同步原理
  16. 计算机一进制一加一等于一,1加1等于几所有答案_灯谜一加一打一字的答案
  17. java多个文件压缩成zip文件
  18. 怎么把短视频做成表情包?短视频制作gif只需三步
  19. 微信小助手 for mac(WeChatPlugin)使用攻略
  20. [c/c++]trivial/POD类型和standard layout

热门文章

  1. C++——random库中的uniform_int_distribution
  2. 【ICLR2019】Oral 论文汇总
  3. 算法—两个有序数组的中位数 Median of Two Sorted Arrays
  4. 0923html测试
  5. 02-mysql数据库的特点-卸载-安装-配置-mysql5.5版本
  6. -bash: mysql: command not found解决方法(zabbix监控mysql失败)
  7. codeforce 804B Minimum number of steps
  8. 八年数据库之路的感悟
  9. 在Ubuntu下面编译WizNote Qt Project
  10. Oracle 11g安装(window)的7个服务