当前位置:网站首页>Go common judgments
Go common judgments
2022-06-30 06:01:00 【Flower master】
var str string The string is initialized to "" Only through len(str) Not through nil Judge
var i int int Initialize to 0 , Only through i == 0, Not through nil Judge
var b bool Initialize to false, Only through b == true , Not through nil Judge
var bb []byte Initialize to [], It can be used len(bb) or bb == nil , Not through bb == "" Judge
var c [1] int Initialize to [0] Filled with default values 0, It can be used len(c) or cap(c), But can't use c== nil perhaps c = "" Judge
var d []string Initialize to [], It can be used d == nil || len(d) > 0 || cap(len) > 0 , But can't use d == "" Judge
var e map[string]int Initialize to [], It can be used e == nil || len(e) > 0 , But can't use e == "" Judge
var f interface{} Initialize to nil, It can be used f == nil , But can't use f=="" ||len(f) > 0 Judge
var g chan string Initialize to nil, It can be used g == nil ||len(g) > 0 || cap(g) > 0 , But can't use g == "" Judge
var h *string Initialize to nil, Only use h == nil Judge
nil Types of support
var nil Type // Type must be a pointer, channel, func, interface, map, or slice type
struct{} This cannot be judged by the above
边栏推荐
- 重构之美:当多线程批处理任务挑起大梁 - 万能脚手架
- Sound net, debout dans le "sol" de l'IOT
- 文件操作IO-Part1
- Simple use of qlistview of QT (including source code + comments)
- How to create a CSR (certificate signing request) file?
- InputStream to inputstreamsource
- inno setup 最简单的自定义界面效果
- MySQL存储系统
- UE4_ Editor UMG close window cannot destroy UMG immediately
- Solidity - Security - reentrancy attack
猜你喜欢

Lantern Festival | maoqiu technology and everyone "guess riddles and have a good night"

Tornado frame foundation

Transfer the token on the matic-erc20 network to the matic polygon

Sword finger offer 18 Delete the node of the linked list

Sword finger offer 22 The penultimate node in the linked list

Develop stylelint rules from zero (plug-ins)

Implementation of property management system with ssm+ wechat applet

Xctf attack and defense world crypto advanced area

8 ways to earn passive income

86. separate linked list
随机推荐
Use of tornado template
[regular expression series] greedy and non greedy patterns
STM32F103 series controlled OLED IIC 4-pin
At the beginning of 2022, people who are ready to change jobs should pay attention to
网络基础知识
ES6解构赋值
86. separate linked list
Prototype and prototype chain in JS
Inno setup the simplest user-defined interface effect
What do you think of the deleted chat records? How to restore the deleted chat records on wechat?
Dao -- a beautiful new world?
Codeforces C. Andrew and Stones
[GPU] basic operation
Do you know how to show the health code in only 2 steps
VLAN access mode
There is a group of students' score {99, 85, 82, 63, 60}. To add a student's score, insert it into the score sequence and keep the descending order
Solidity - Security - reentrancy attack
Solidity - 安全 - 重入攻击(Reentrancy)
ECS deployment web project
ES6箭头函数